akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define f first
#define se second
#define pb push_back
#define pf push_front
#define eb emplace_back
#define emp emplace
#define ins insert
#define sz(s) (int)s.size()
#define rep(i,a,b) for( int i=a;i<b;i++)
#define repr(i,a,b) for( int i=a;i>=b;i--)
#define bitcount __builtin_popcount
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(n,m) memset(n,m,sizeof(n))
#define ii pair<int,int>
#define iii tuple<int, int, int>
#define si set<int>
#define vi vector<int>
#define vii vector<ii>
#define mi map<int,int>
#define lb lower_bound
#define ub upper_bound
#define present(s,x) (s.find(x) != s.end())
#define ford(container, it) for(auto it:container)
#define fors(container, it, a, b) for(auto it = a; it != b; it++)
#define Anurag_Gupta ios_base::sync_with_stdio(0);
#define IIIT_ALLD cin.tie(0);cout.tie(0);
#define mod 987654319
#define EPSILON 1e-9
#define PI acos(-1)
#define inf 1e17
#define int long long
#define debug(a) cerr<<#a<<": ";for(auto i:a)cerr<<i<<" ";cerr<<'\n';
#define trace(a) cerr<<#a<<": "<<a<<"\n"
#define gcd(a,b) __gcd(a,b)
using namespace std;
int add(int a, int b, int c){int res=a+b;return(res>=c?res-c:res);}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
int mul(int a, int b, int c){int res=(int)a*b;return(res>=c?res%c:res);}
template<typename T>T power(T e, T n){T x=1,p=e;while(n){if(n&1)x=x*p;p=p*p;n>>=1;}return x;}
template<typename T>T mdpower(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mul(x,p,m);p=mul(p,p,m);n>>=1;}return x;}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
/*------------------------------------------------------------------------------------------------------------------*/

bool cmp(const ii a,const ii b)
{
    if(a.se==b.se)
        return a.f<b.f;
    return a.se<b.se;
}
int32_t main()
{
    Anurag_Gupta
    IIIT_ALLD

  


        int n;
        cin>>n;
        vii v;
        rep(i,0,n)
        {
            int a,b;
            cin>>a>>b;
            v.pb({a,b});
        }

        sort(all(v),cmp);

        int flag=0;
        int sum=0;
        ford(v,it)
        {
            sum+=it.f;
            if(sum>it.se)
                flag=1;
        }

        cout<<(flag?"No":"Yes");









   
}


Measured memory_bytes: 6512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mxn=5e5+5;
int n,k;
ll a[mxn],s[mxn],ans;
vector<ll>v;map<ll,int>m;
struct fenwick{
	int t[mxn],sz;
	inline void init(int siz){memset(t,0,sizeof(t));sz=siz;}
	inline void add(int x,int val){for(int i=x;i<=sz;i+=(i&-i))t[i]+=val;}
	inline int ask(int x){int rt=0;for(;x;x-=(x&-x))rt+=t[x];return rt;}
}fen;
int main(){
	ios_base::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=1;i<=n;++i)cin>>a[i],a[i]-=k;
	for(int i=1;i<=n;++i)s[i]=s[i-1]+a[i],v.push_back(s[i]),ans+=(s[i]>=0);
	sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end());
	for(int i=0;i<v.size();++i)m[v[i]]=i+1;
	for(int i=1;i<=n;++i)s[i]=m[s[i]];
	fen.init(n*2);
	for(int i=1;i<=n;++i){
		ans+=fen.ask(s[i]);
		fen.add(s[i],1);
	}
	cout<<ans<<'\n';
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  // deque<pair<LD,int>> ans;
  // ans.push_back({0,0});
  // int x,sum;
  // LD a;
  // for(int i=1;i<100000000;i++){
  //   x=i,sum=0;
  //   while(x){
  //     sum+=x%10;
  //     x/=10;
  //   }
  //   a=(LD)i/sum;
  //   while(ans.back().first>a){
  //     ans.pop_back();
  //   }
  //   ans.push_back({a,i});
  // }
  // while(!ans.empty()){
  //   cout << ans.front().second << endl;
  //   ans.pop_front();
  // }
  int k;
  cin >> k;
  deque<pair<LD,LL>> ans;
  ans.push_back({0,0});
  LL x,sum;
  LD a;
  for(int i=1;i<10000;i++){
    x=i,sum=0;
    while(x){
      sum+=x%10;
      x/=10;
    }
    a=(LD)i/sum;
    while(ans.back().first>a){
      ans.pop_back();
    }
    ans.push_back({a,i});
  }
  LL now=100;
  for(int i=0;i<12;i++){
    for(int j=100;j<1000;j++){
      x=j*now+now-1,sum=0;
      while(x>0){
        sum+=x%10;
        x/=10;
      }
      a=(LD)(j*now+now-1)/sum;
      // cout << j*now+now-1 SP sum SP a << endl;
      while(ans.back().first>a){
        ans.pop_back();
      }
      ans.push_back({a,j*now+now-1});
    }
    now*=10;
  }
  ans.pop_front();
  for(int i=0;i<k;i++){
    cout << ans.front().second << endl;
    ans.pop_front();
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,l,r) for(int i=l;i<=r;i++)
#define of(i,l,r) for(int i=l;i>=r;i--)
#define fe(i,u) for(int i=head[u];i;i=e[i].next)
#define el putchar('\n')
#define ta putchar('	')
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline void open(const char *s)
{
	#ifndef ONLINE_JUDGE
	char str[20];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
//	sprintf(str,"%s.out",s);
//	freopen(str,"w",stdout);
	#endif
}
inline int rd()
{
	static int x,f;
	x=0;f=1;
	char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return f>0?x:-x;
}
const int N=10010;
int n,K;
char s[N],tmp[N],ans[N];

inline void gao1(char c){fo(i,1,n)putchar(c);el;exit(0);}
inline bool cmp()
{
	if(!ans[1])return 1;
	fo(i,1,n)if(ans[i]!=tmp[i])return ans[i]>tmp[i];
	return 0;
}

int main()
{
	n=rd();K=rd();
	scanf("%s",s+1);
	char mn='z'+1;
	fo(i,1,n)mn=min(mn,s[i]);
	if(K>=14)gao1(mn);
	fo(i,1,n)s[n+i]=s[i];reverse(s+n+1,s+n+n+1);
	if(K==1){
		fo(i,1,n+1)if(s[i]==mn){
			fo(j,i,i+n-1)tmp[j-i+1]=s[j];
			if(cmp())swap(tmp,ans);
		}
		printf("%s\n",ans+1);return 0;
	}
	fo(i,n,n+n)if(s[i]==mn){
		int cnt=1,hh=i;
		while(s[hh-1]==mn)--hh,++cnt;
		if((cnt<<(K-1))>=n)gao1(mn);
		int len=cnt<<(K-1);
		fo(j,1,len)tmp[j]=mn;
		fo(j,1,n-len)tmp[j+len]=s[i-cnt-j+1];
		if(cmp())swap(tmp,ans);
	}
	printf("%s\n",ans+1);
	return 0;
}

Measured memory_bytes: 384
s = gets.chomp
x,y = gets.split.map(&:to_i)

move = [[],[]]
dist = 0
dir = -1
default_x = nil
s.chars {|cmd|
  if cmd == "F"
    dist += 1
  else
    if dir == -1
      default_x = dist
    else
      move[dir] << dist if dist > 0
    end
    dir = dir == 1 ? 0 : 1
    dist = 0
  end
}

if dir == -1
  default_x = dist
else
  move[dir] << dist if dist > 0
end

pos_x = [default_x]
move[0].each do |d|
  nxt = []
  pos_x.each do |p|
    nxt << p+d if p+d < 8001
    nxt << p-d if p-d > -8001
  end
  pos_x = nxt.uniq
end

pos_y = [0]
move[1].each do |d|
  nxt = []
  pos_y.each do |p|
    nxt << p+d if p+d < 8001
    nxt << p-d if p-d > -8001
  end
  pos_y = nxt.uniq
end
puts (pos_x.index(x) && pos_y.index(y)) ? "Yes" : "No"


Measured memory_bytes: 50684
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
int p[210000];
int n;
int sum[210000];
map<pair<int,int>,int>dp;
int calc(int a,int b){
	if(dp.count(make_pair(a,b)))return dp[make_pair(a,b)];
	if(a==n-3)return b;
	if(b<p[n-2-a]){
		return dp[make_pair(a,b)]=calc(a+1,p[n-2-a]-b);
	}
	int ret=0;
	int at=upper_bound(sum,sum+n-2,sum[a]+b)-sum-1;
	int tb=b-(sum[at]-sum[a]);
	ret=calc(at,tb);
	return dp[make_pair(a,b)]=ret;
}
int main(){
	int a;scanf("%d",&a);
	n=a;
	for(int i=0;i<a-1;i++){
		scanf("%d",p+i);
	}
	for(int i=0;i<a-1;i++){
		sum[i+1]=sum[i]+p[a-2-i];
	}
	int b;scanf("%d",&b);
	for(int i=0;i<b;i++){
		int x;scanf("%d",&x);
		int ret=calc(0,x)+p[0]-p[1];
		printf("%d\n",ret);
	}
}

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

int a[100001] , n ,ans ;
int main()
{

    cin >> n ;
    for (int i = 0 ;i < n ; i++)cin >>a[i];
    sort(a ,a + n);
    n/=2;
    cout <<a[n ] - a[n - 1];

    return 0;
}


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

int main(){
    int n;cin >> n;
    set<int> mochi;
    for(int i=0;i<n;++i){
        int a; cin >> a;
        mochi.insert(a);
    }
    cout << mochi.size() << endl;
    return 0;
}

Measured memory_bytes: 256
/*
* Welcome to my code!
*---------------------------------------------*
* author : lynmisakura(twitter : @andoreiji11)
*/
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define repn for(int i = 0;i < n;i++)
#define ain(a) for(auto& i : a)cin >> i;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size()) 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define cont continue

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using pi = pair<int,int>;
using vpi = vector<pi>;
using pl = pair<ll,ll>;
using vpl = vector<pl>;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
template<class T> void print(std::vector<T> a)
{ int sz = a.size(); for(int i=0;i<a.size();i++)cout << a[i] << (i < sz-1 ? ' ' : '\n'); }
void ioboost(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}
///////////////////////////////////////////////////////////

ll cost[13];
ll a[13][13];
int main(int argc, char const *argv[])
{
  ioboost();
  
  ll n,m,x;cin >> n >> m >> x;

  rep(i,n){
    cin >> cost[i];
    rep(j,m)cin >> a[i][j];
  }
  ll ans = LONG_MAX;
  rep(i,1 << n){
    ll cur = 0;
    vector<ll> cal(m,0);
    rep(j,n){
      if(i >> j & 1){
        cur += cost[j];
        rep(k,m)cal[k] += a[j][k];
      }
    }
    int ok = 1;
    rep(j,m)if(cal[j] < x)ok = 0;
    if(ok){
      chmin(ans,cur);
    }
  }
  if(ans == LONG_MAX)cout << -1 << '\n';
  else cout << ans << '\n';
  return 0;
}

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

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

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

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

signed main() {
  INIT;
	VAR(string, s);
	int b_cnt = 0, ans = 0;
	REP(i,s.size()){
		if(s[i] != 'B') continue;
		ans += s.size() - i - 1;
		++b_cnt;
	}

	ans -= b_cnt * (b_cnt - 1) / 2;
	OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 720
#include <cstdio>
#include <iostream>
using namespace std;
const int maxN = 2e5 + 5, mod = 1e9 + 7;
int n, k, fac[maxN * 2], inv[maxN * 2], facInv[maxN * 2];
void Init() {
	fac[0] = 1;
	for (int i = 1; i <= maxN << 1; ++i)
		fac[i] = 1ll * fac[i - 1] * i % mod;
	inv[1] = 1;
	for (int i = 2; i <= maxN << 1; ++i)
		inv[i] = 1ll * (mod - (mod / i)) * inv[mod % i] % mod;
	facInv[0] = 1;
	for (int i = 1; i <= maxN << 1; ++i)
		facInv[i] = 1ll * facInv[i - 1] * inv[i] % mod;
}
int C(int n, int m) {
	return 1ll * fac[n] * facInv[n - m] % mod * facInv[m] % mod;
}
int Add(int fir, int sec) {
	return (fir + sec) % mod;
}
int main() {
	Init();
	scanf("%d%d", &n, &k);
	int ans = 0;
	for (int i = 0; i <= min(n, k); ++i)
		ans = Add(ans, 1ll * C(n - i + i - 1, n - i - 1) * C(n, i) % mod);
	printf("%d\n", ans);
	return 0;
}

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

namespace JagArrayTest
{
    class Program
    {
        static void Main(string[] args)
        {
            while(true)
            {
                var readline = Console.ReadLine();

                if(readline == null)
                {
                    break;
                }

                var d = readline.Split(' ').ToList().ConvertAll(double.Parse).ToArray();
                Console.WriteLine((d[0] + d[1]).ToString().Length);
            }

        }
    }
}


Measured memory_bytes: 16320
@S=(1)x(@p=@i=0..10**5);
$%-=<>;
sub f{my$U=pop;$p[$U]=$U-$p[$U]?f($p[$U]):$U}
/ />${*a=-$'}||((f$a)-(f$`)and$S[f$`]+=$S[f$a],$p[f$a]=f$`),$a=$`for<>;
$%+=($u=${-$_})>0&&$S[f$u]for@i;
print$%

Measured memory_bytes: 56576
#include<iostream>
using namespace std;
int main(){
	int a, b, c; cin>>a>>b>>c;
	int x = min(a, b);
	for(int i=x; i>0; i--){
		if(a%i==0 && b%i==0){
			--c;
			if(c==0) {cout<<i<<endl; break;}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
     string s;
     cin>>s;

     if(s[2] == s[3] && s[4] == s[5])
     	cout<<"Yes";
     else
     	cout<<"No";
 	 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> A;
    vector<int> B;
    int inp;
    for(int i=0; i<N; i++){
        cin >> inp;
        A.push_back(inp);
        B.push_back(inp);
    }
    sort(B.begin(),B.end());
    int Big1=B.at(N-1);
    int Big2=B.at(N-2);
    for(int i=0; i<N; i++){
        if(A.at(i)==Big1){
            cout << Big2 << endl;
        }else{
            cout << Big1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3436
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int MOD = 1_000_000_007;
		int N = sc.nextInt();
		int K = sc.nextInt();
		long[] A = new long[N];
		int neg = 0, zero = 0, plus = 0;
		long ans = 1;
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextLong();
			if(A[i] > 0)
				plus++;
			else if(A[i] == 0)
				zero++;
			else
				neg++;
		}
		if((neg / 2 * 2) + plus >= K && (plus != 0 || K % 2 == 0)) {
			// ans > 0
			Arrays.sort(A);	
			List<Long> l = new ArrayList<>();
			for(int i = 1; i < N; i+=2) {
				if(A[i] >= 0)
					break;
				l.add(A[i] * A[i-1]);
			}
			if(K % 2 == 1) {
				ans = A[N-1];
				K--;
				N--;
			}
			for(int i = N-2; i >= 0; i-=2) {
				if(A[i] <= 0)
					break;
				l.add(A[i] * A[i+1]);
			}
			Collections.sort(l, Collections.reverseOrder());
			for(int i = 0; i < K / 2; i++)
				ans = ans * (l.get(i) % MOD) % MOD;
			System.out.println(ans);
		}
		else {
			// ans <= 0
			if(zero > 0) {
				System.out.println(0);
				return;
			}
			// ans < 0
			long[] abs = new long[N];
			for(int i = 0; i < N; i++)
				abs[i] = Math.abs(A[i]);
			Arrays.sort(abs);
			ans = -1;
			for(int i = 0; i < K; i++)
				ans = ans * abs[i] % MOD;
			System.out.println((ans + MOD) % MOD);
		}
	}

}

Measured memory_bytes: 61944
args = input().split()

h, w = int(args[0]), int(args[1])

array = []

hoge = ""

for i in range(w + 2):
    hoge += "."

array.append(hoge)
for y in range(h):
    args = "." + input() + "."

    array.append(args)

array.append(hoge)

result = []
for iy in range(h):
    result = ""
    for ix in range(w):
        y = iy + 1
        x = ix + 1
        count = 0
        if array[y][x] == "#":
            result += "#"
        else:
            for fx in [-1, 0, 1]:
                for fy in [-1, 0, 1]:
                    if array[y + fy][x + fx] == "#":
                        count += 1
            result += str(count)
    print(result)


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

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

  if (a < b && b < c) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> p;
    for (ll i = 0; i < n; i++)
    {
        ll a, b;
        cin >> a >> b;
        p.push_back(make_pair(a, b));

    }
    ll cnt = 0;
    ll cost = 0;
    sort(p.begin(), p.end());
    for (ll i = 0; i < n; i++)
    {
        ll a = p[i].first;
        ll b = p[i].second;
        ll diff = m - cnt;
        if(diff>b)
        {
            cost += a*b;
            cnt += b;
        }
        else
        {
            cost += a * diff;
            cnt += diff;
        }
    }
    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 2420
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iostream>
#include<cmath>
#include<map>
#include<set>
#include<climits>
using namespace std;
typedef vector<string>vs;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<double>vd;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll>pll;
typedef vector<ll>vl;
typedef pair<int,pii>piii;
#define rrep(i,x,n) for(int i=(x);i<(n);++i)
#define rep(i,x) rrep(i,0,(x))
#define fi first
#define se second
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define maxs(a,b) (a)=max(a,b)
#define mins(a,b) (a)=min(a,b)
///#include<sstream>
///#include<cstring>
///#include<stack>
///#include<complex>

int W,H;
char fld[100][101];
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};
int solve(){
    bool done[100][100]={{0}};
    priority_queue<piii,vector<piii>,greater<piii> >Q;
    rep(i,H){
        Q.push(piii(0,pii(i,0)));
        Q.push(piii(0,pii(i,W-1)));
    }
    rep(j,W){
        Q.push(piii(0,pii(0,j)));
        Q.push(piii(0,pii(H-1,j)));
    }

    while(!Q.empty()){
        piii p=Q.top();Q.pop();
        if(done[p.se.fi][p.se.se])continue;
        done[p.se.fi][p.se.se]=true;
        if(fld[p.se.fi][p.se.se]=='&')return p.fi;

        rep(i,4){
            int ty=p.se.fi+dy[i],tx=p.se.se+dx[i];
            if(ty<0||ty>=H||tx<0||tx>=W)continue;
            int tcost=p.fi;
            if(fld[p.se.fi][p.se.se]=='#'&&fld[ty][tx]!='#')tcost++;
            Q.push(piii(tcost,pii(ty,tx)));
        }
    }
}

int main(){
    while(scanf("%d%d",&W,&H),W||H){
        rep(i,H)scanf("%s",fld[i]);
        printf("%d\n",solve());
    }
    return 0;
}

Measured memory_bytes: 1424
#include <bits/stdc++.h>
#define All(v) v.begin(), v.end()
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

const int MAX_N = (int)1e5 + 5;
int dist[MAX_N][3], N, M, S, T;
vector<int> G[MAX_N];

void bfs(int s){
    dist[s][0] = 0;
    queue<pii> q;
    q.push(pii(s, 0));
    while(!q.empty()){
        int u = q.front().first, c = q.front().second;
        q.pop();
        for(auto v : G[u]){
            if(dist[v][(c+1)%3]>-1) continue;
            dist[v][(c+1)%3] = dist[u][c] + 1;
            q.push(pii(v, (c+1)%3));
        }
    }
}

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    cin>>N>>M;
    for(int i=0;i<M;i++){
        int u, v;
        cin>>u>>v, u--, v--;
        G[u].push_back(v);
    }
    cin>>S>>T, S--, T--;
    for(int i=0;i<N;i++) for(int j=0;j<3;j++) dist[i][j] = -1;
    bfs(S);
    if(dist[T][0]==-1) cout<<-1<<endl;
    else cout<<dist[T][0] / 3<<endl;
    return 0;
}

Measured memory_bytes: 6912
// luogu-judger-enable-o2
// luogu-judger-enable-o2
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
using namespace std;
int d[2005],h[2005],vst[2005],cnt,n,m,s[2005];
struct Edge{
    int to,next,value;
}e[10005];
struct Heap_Node{
    int dis,no;
    bool operator <(const Heap_Node K) const{
        return dis>K.dis;
    }
};
priority_queue<Heap_Node>q;
void Add_Edge(int u,int v,int w){
    e[++cnt].to=v;
    e[cnt].value=w;
    e[cnt].next=h[u];
    h[u]=cnt;
}
void Read_In(){
	int x,y;
    scanf("%d%d%d",&n,&x,&y);
    Add_Edge(x,y,1);
    Add_Edge(y,x,1);
    for(int i=1;i<n;i++){
    	Add_Edge(i,i+1,1);
    	Add_Edge(i+1,i,1);
    }
}
void Dijkstra(int start){
	memset(vst,0,sizeof(vst));
    memset(d,0x3f,sizeof(d));
    d[start]=0;
    q.push((Heap_Node){d[start],start});
    while(!q.empty()){
        Heap_Node u=q.top();
        q.pop();
        if(vst[u.no])continue;
        vst[u.no]=1;
        for(int i=h[u.no];i;i=e[i].next){
            int t=e[i].to,v=e[i].value;
            if(!vst[t]&&d[t]>d[u.no]+v){
                d[t]=d[u.no]+v;
                q.push((Heap_Node){d[t],t});
            }
        }
    }
    for(int i=1;i<=n;i++)s[d[i]]++;
}
int main(){
    Read_In();
    for(int i=1;i<=n;i++)Dijkstra(i);
    for(int i=1;i<n;i++)cout<<s[i]/2<<endl;
    return 0;
}


Measured memory_bytes: 384
n = int(input())
def make_divisors(n):
    k = 0
    divisors = []
    for i in reversed(range(1, int(n**0.5)+1)):
        if n % i == 0:
            k = i
            break
    # divisors.sort()
    return k
k = make_divisors(n)
kk = n // k
print(kk + k - 2)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)


int uniquell(ll*a,ll*ans,int cnt){
	sortup(a,cnt);
	int c=0;
	ans[0]=a[0];
	rep(i,1,cnt)if(a[i]!=ans[c])ans[++c]=a[i];
	return c+1;
}
//座圧2
//前準備：
//圧縮したい配列aに-INFとINFを追加する
//uniquell(a,comp,n)でcompに昇順の配列を作る
ll comp[200010],compcnt;
ll cocompf(ll n){
	//comp[i]<=n<comp[i+1]なるiを返す
	ll l=0,r=compcnt;
	while(r-l>1){
		ll m=(l+r)/2;
		if(comp[m]<=n)l=m;
		else r=m;
	}
	return l;
}

ll a[200010];
ll t[200010];
ll dp[100][200010];
ll pre[200010];
ll st[200010],stcnt;
ll temp[200010];
int main(){
	ll n,kk;
	scanf("%lld%lld",&n,&kk);
	rep(i,0,n)scanf("%lld",a+i),t[i]=a[i];
	compcnt=uniquell(t,comp,n);
	rep(i,0,n)pre[i]=-1;//直前にiが登場した位置
	rep(i,0,2*n){
		int j=cocompf(a[i%n]);
		if(pre[j]!=-1)dp[0][pre[j]%n]=i-pre[j]+1;
		pre[j]=i;
	}
	rep(k,1,90)rep(i,0,n){
		ll t=dp[k-1][i]+dp[k-1][(i+dp[k-1][i])%n];
		if(dp[k-1][i]>=3e17||t>=3e17)dp[k][i]=3e17;
		else dp[k][i]=t;
	}
//	rep(k,0,90){rep(i,0,n)printf("%lld ",dp[k][i]);puts("");}fflush(0);
	ll crr=0;
	while(crr+dp[0][crr%n]<=n*kk){
		for(int k=88;k>=0;k--)if(crr+dp[k][crr%n]<=n*kk){
			crr+=dp[k][crr%n];
			break;
		}
	}
	if(crr!=n*kk){
		rep(i,crr%n,n){
			int j=cocompf(a[i]);
			if(temp[j]){
				while(temp[j])temp[st[--stcnt]]--;
			}else{
				st[stcnt++]=j;
				temp[j]++;
			}
		}
		rep(i,0,stcnt)printf("%lld ",comp[st[i]]);
	}
}

Measured memory_bytes: 152928
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long 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; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll d = c - a - b;
    cout << (0 <= d && 4 * a * b < d * d ? "Yes" : "No") << endl;
}

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

int main(){
	
	int n,m;
	
	cin>>n>>m;
	
	vector<int> t(m);
	vector<int> sum(n);
	vector< vector<int> > a(m,vector<int>(n) );
	for(int i=0;i<m;i++){
		cin>>t[i];
	}
	
	for(int i=0;i<m;i++){
			int k=0;
		for(int j=0;j<n;j++){
			cin>>a[i][j];
			if(t[i]==a[i][j])
				sum[j]+=1;
			else
				k++;
		}
		sum[t[i]-1]+=k;
	}
	for(int i=0;i<n;i++)
		cout<<sum[i]<<endl;
	
	
	
}

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

#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
#define OMAZINAI cin.tie(0); ios::sync_with_stdio(false);
#define INF (1LL<<61)
typedef long long int ll;

int flag[300];
int main() {
	OMAZINAI;
	std::vector<int> tmp = { 3, 5, 7, 11, 13, 17 };
	int cnt = 0, N, t;
	cin >> N;
	auto add = [&](int n) {
		if(n <= N)
			if (!flag[n]) {
				++cnt;
				flag[n] = 1;
			}
	};
	for (int i : tmp)
			add(std::pow(i, 7));
	for (int i : tmp)
		for (int n : tmp)
			if (i - n)
				add(i*pow(n, 3));
	for (int i : tmp)
		for (int n : tmp)
			for (int t : tmp)
				if (i - n && n - t && t - i)
					add(i*n*t);
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func Perm(a []rune, f func([]rune)) {
	perm(a, f, 0)
}

func perm(a []rune, f func([]rune), i int) {
	if i > len(a) {
		f(a)
		return
	}
	perm(a, f, i+1)
	for j := i + 1; j < len(a); j++ {
		a[i], a[j] = a[j], a[i]
		perm(a, f, i+1)
		a[i], a[j] = a[j], a[i]
	}
}

func Abs(x int) int {
	if x > 0 {
		return x
	}

	return - x
}

func main() {
	n := nextInt()

	p := ""
	for i := 0; i < n; i++ {
		p += fmt.Sprint(nextInt())
	}

	q := ""
	for i := 0; i < n; i++ {
		q += fmt.Sprint(nextInt())
	}

	s := ""
	for i := 1; i<=n; i++ {
		s += fmt.Sprintf("%d", i)
	}

	var pIndex int
	var qIndex int

	perms := []string{}
	Perm([]rune(s), func(a []rune) {
		perms = append(perms, string(a))
	})

	sort.Strings(perms)
	for index, a := range perms {
		if a == p {
			pIndex = index
		}
		if a == q {
			qIndex = index
		}
	}
	fmt.Printf("%d", Abs(qIndex - pIndex))
}


Measured memory_bytes: 4864
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())

def main():
    s = ['Sunny', 'Cloudy', 'Rainy']
    print(s[(s.index(input())+1)%3])

main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using namespace atcoder;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}
__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    int n, q;
    cin >> n >> q;
    fenwick_tree<ll> ft(n);
    rep(i, n) {
        int a;
        cin >> a;
        ft.add(i, a);
    }
    while (q--) {
        int t;
        cin >> t;
        if (t == 0) {
            int p, x;
            cin >> p >> x;
            ft.add(p, x);
        } else {
            int l, r;
            cin >> l >> r;
            cout << ft.sum(l, r) << '\n';
        }
    }
}


Measured memory_bytes: 8252
/*input
2
1 2
3
1 100
2 100
100 1000
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long int


signed main(){


    int n;
    cin >> n ;
    vector<int> a(n);
    map< int ,int > m;
    int sum =0;
    for ( int i = 0 ; i < n ; i++) {
        cin >> a[i]; m[a[i]]++;
        sum += a[i];
    }

    int q;
    cin >>q;
    while( q--){
        int b ,c;
        cin >> b >> c;
        sum -= m[b] * b;
        sum += m[b] *c;
        int x = m[b];
        m.erase(b);
        m[c] += x;
        cout << sum <<"\n";
    }


}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};


struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main() {
  Sieve sieve(1e6);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  map<int,int> mp;
  rep(i,n) {
    auto f = sieve.factor(a[i]);
    for (auto p : f) {
      mp[p.first] = max(mp[p.first], p.second);
    }
  }

  mint lcm = 1;
  for (auto p : mp) {
    rep(i,p.second) {
      lcm *= p.first;
    }
  }

  mint ans;
  rep(i,n) {
    mint b = lcm/a[i];
    ans += b;
  }
  cout << ans.x << endl;
  return 0;
}


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

int bubbleSort(vector<int> &a, int n) {
  int sw = 0;
  int flag = 1;
  for (int i = 0; flag; i++) {
    flag = 0;
    for (int j = n - 1; j > i; j--) {
      if (a.at(j - 1) > a.at(j)) {
        swap(a.at(j - 1), a.at(j));
        flag = 1;
        sw++;
      }
    }
  }
  return sw;
}

int main() {
  int n, sw;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);

  sw = bubbleSort(a, n);

  for (int i = 0; i < n; i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << a.at(i);
  }
  cout << endl;
  cout << sw << endl;

  return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const int mod = 100000;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  ll n;
  cin >> n;
  int f = 0;
  for(auto c : to_string(n)) f += c-'0';
  if(n%f == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i,a,b) for(int i= a; i < b; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
string s;
int q;
int cnt = 0;
bool is_front = true;

string solver() {
  deque<char> dq;
  for(char &c : s) dq.push_back(c);
  
  rep(i, q) {
    int m;
    cin >> m;
    if (m == 1) {
      is_front = !is_front;
      cnt++;
    } else {
      int f;
      char c;
      cin >> f >> c;
      if (f == 1) {
        if (!is_front) {
          dq.push_back(c);
        } else {
          dq.push_front(c);
        }
      } else {
        if (!is_front) {
          dq.push_front(c);
        } else {
          dq.push_back(c);
        }        
      }
    }
  }
  string ans = ""; 
  if (!is_front) {
    for(auto it = dq.rbegin(); it != dq.rend(); it++) {
      ans +=  *it;
    }
    return ans;
  } else {
    for(auto it = dq.begin(); it != dq.end(); it++) {
      ans += *it;
    }
    return ans;
  }
}

int main()
{
  cin >> s >> q;
  string a = solver();
  
  cout << a << endl;

 return 0;
}

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

int one_c[35];

main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		int a;
		queue<int> s;
		scanf("%d",&a);
		while(a>0)
		{
			s.push(a%2);
			a/=2;
		}
		int nw=0;
		while(!s.empty())
		{
			//printf("%d ",s.front());
			if(s.front()==1)
				one_c[nw]++;
			s.pop();
			nw++;
		}
		//printf("\n");
	}
	int err=0;
	for(int i=0;i<34;i++)
	{
		//printf("%d ",one_c[i]);
		if(one_c[i]==0)continue;
		else if(one_c[i]%2==0&&(one_c[i]/2)*3==n)continue;
		else err++;
	}
	if(err==0)printf("Yes\n");
	else printf("No\n");
}

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

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  int tot = 0;
  for (int i = 0; i < 3; i++) {
    tot += s[i] == t[i];
  }
  cout << tot << '\n';
  return 0;
}



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


int main() {
int N, K;
  int sum = 0;
  
  cin >> N >> K;
  for (int i = 0; i < N; ++i){
    int x;
    cin >> x;
    if(2*x <= 2*(K -x)){
      sum += 2*x;
    }
    else{
      sum += 2*(K -x);
    }
    
  }
  cout << sum << endl;
    
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  ll n, k;
  cin >> n >> k;
  ll ans = LONG_MAX;
  ans = min(n % k, abs(n % k - k));
  cout << ans << endl;
}

Measured memory_bytes: 256
/* 
 author:hdsdogge 
 begin: 
 end: 
 cost: 
 */
#include<iostream>
#include<string>
#include<queue>
#include<map>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<vector>
#include<bitset>
#include<cstdlib>
#include<list>
#include <sstream>
#include<ctype.h>
using namespace std;
const int maxn=1000000+10;
typedef pair<int,int> P;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
int T,n,m;
int par[maxn];
int vis[maxn];
int main() {
   // freopen("test","r",stdin);
   // freopen("out","w",stdout);
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    while(cin>>n>>m&&(n+m)){
        memset(vis,0, sizeof(vis));
        par[1]=1;
        vis[1]=1;
        ll ans=0;
        for(int i=2;i<=n;i++){
            int x;
            cin>>x;
            par[i]=x;
        }
        for(int i=0;i<m;i++){
            char c;
            int x;
            cin>>c>>x;
            if(c=='Q'){
                while(vis[x]==0){
                    x=par[x];
                }
                ans+=x;
            }
            else if(c=='M'){
               vis[x]=1;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
} 




Measured memory_bytes: 7412
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <random>
#include <string.h>      //文字列の代入に使う
#include <bits/stdc++.h> //piの利用で必要(M_PI)
#include <algorithm>

int main()
{

    int N, M, count = 0;
    std::cin >> N >> M;

    int digit = 0; //log(N) / log(K);
    std::vector<int> value(3);
    std::vector<int> s(M), c(M);
    for (int i = 0; i < M; i++)
    {
        std::cin >> s.at(i) >> c.at(i);
        //std::cout << s.at(i) << c.at(i) << std::endl;
        //std::cout << i << std::endl;
    }

    for (int i = 0; i < 1000; i++)
    {

        digit = log(i) / log(10) + 1;
        if (i == 0)
        {
            digit = 1;
        }
        if (digit == N)
        {
            for (int j = 0; j < M; j++)
            {
                if ((int)(i / pow(10, N - s.at(j))) % 10 == c.at(j))
                {
                    count++;
                }
            }
            if (count == M)
            {
                std::cout << i << std::endl;
                return 0;
            }
            else
            {
                count = 0;
            }
        }
    }
    std::cout << -1 << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
const double pi = atan2(0.0, -1.0);
int main(){
    cout << fixed << setprecision(10);
    double a,b,x; cin >> a >> b >> x;
    double ans;
    if((2.0*x) <= (a*a*b)){
        ans = atan2(a*b*b, 2.0*x);
        ans *= (double)(180.0/pi);
    }
    else{
        ans = atan2((2.0*a*a*b - 2.0*x), a*a*a);
        ans *= (double)(180.0/pi);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int x;

    cin >> x;

    for(int a = 0; a < 200; a++){
        for(int b = -200; b < 200; b++){
            int num = a * a * a * a * a - b * b * b * b * b;
            if(num == x){
                cout << a << " " << b << endl;
                return 0;
            }
        }
    }

    cout << "¯\\_(ツ)_/¯" << endl;

    return 0;
}

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, M; cin >> N >> M;
  vector nxt(N, vector<ll>());
  for (ll i = 0; i < M; i++) {
    ll a, b; cin >> a >> b; a--; b--;
    nxt[a].push_back(b);
  }

  vector seen(N, false);
  vector on_path(N, false);
  vector<ll> path;

  auto refine = [&](ll start) -> void {
    ll sz = path.size();
    vector rf_next(N, 0LL);
    for (ll i = 0; i+1 < sz; i++) {
      rf_next[path[i]] = path[i+1];
    }
    rf_next[path[sz-1]] = start;
    ll cur = path[0];
    while (cur != start) {
      on_path[cur] = false;
      cur = rf_next[cur];
    }
    ll top = cur;
    ll cnt = 0;
    do {
      for (ll m : nxt[cur]) {
	if (on_path[m] && m != rf_next[cur]) {
	  ll rem = rf_next[cur];
	  while (rem != m) {
	    on_path[rem] = false;
	    rem = rf_next[rem];
	  }
	  rf_next[cur] = m;
	  top = cur;
	  cnt = 0;
	}
      }
      cur = rf_next[cur];
      cnt++;
    }while (cur != top);
    cout << cnt << "\n";
    do {
      cout << cur + 1 << "\n";
      cur = rf_next[cur];
    }while (cur != top);

    exit(0);
  };

  auto dfs = [&](auto rF, ll n) -> void {
    if (on_path[n]) refine(n);
    if (seen[n]) return;
    on_path[n] = true;
    path.push_back(n);
    seen[n] = true;
    for (ll m : nxt[n]) rF(rF, m);
    on_path[n] = false;
    path.resize(path.size() - 1);
  };

  for (ll i = 0; i < N; i++) dfs(dfs, i);
  cout << -1 << endl;
  return 0;
}



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

int solve(int n) { 
    int cnt = 0;
    while (n%2==0) {
      n /= 2;
      cnt++;
    }
    return cnt;
}

int main() { 
    int n, check=0,out=1;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      if (check != max(check, solve(i))) {
        out = i;
        check = max(check, solve(i));
      }
      else
        continue;
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 3604
input_number = input()
input_list = input_number.split()
coding_contest_rank = int(input_list[0])
robot_maneuver_rank = int(input_list[1])

if coding_contest_rank == 1:
    coding_contest_money = 300000
if robot_maneuver_rank == 1:
    robot_maneuver_money = 300000
if coding_contest_rank == 2:
    coding_contest_money = 200000
if robot_maneuver_rank == 2:
    robot_maneuver_money = 200000
if coding_contest_rank == 3:
    coding_contest_money = 100000
if robot_maneuver_rank == 3:
    robot_maneuver_money = 100000
if coding_contest_rank > 3:
    coding_contest_money = 0
if robot_maneuver_rank > 3:
    robot_maneuver_money = 0
if coding_contest_rank == 1 and robot_maneuver_rank == 1:
    total_money = coding_contest_money + robot_maneuver_money + 400000
    print(total_money)    
else:
    print(coding_contest_money + robot_maneuver_money)

Measured memory_bytes: 3064