akhauriyash/Code-Regression huggingface dataset:
/* ****revpro**** */
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;

#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define N  100005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
void solve()
{
	ll n;
	cin>>n;
	ll ans=1;
	long double s=0;
	rep(i,0,n){
		ll x;
		cin>>x;
		if(x==0) {
			cout<<0;
			return ;
		}
		ans*=x;
		s+=log(x);
	}
	if(s>log(1e18)) {
		cout<<-1;
		return ;
	}
	cout<<ans<<endl;
}	
signed main()
{
	
		/***********************************/
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    mt19937_64 generator (seed);
    /***********************************/
 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
		
	}
	TIME
	return 0;
}

Measured memory_bytes: 4016
#include<iostream>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)
ll INF=1e13;

int main(){
  ll n,x,a[2010],t[2010][2010],k=0,c=INF;
  cin>>n>>x;
  fr(i,n) cin>>a[i];
  fr(i,n){
    t[i][0]=a[i];
    fr(j,n-1){
      if(a[(i-j-1+n)%n]<t[i][j]) t[i][j+1]=a[(i-j-1+n)%n];
      else t[i][j+1]=t[i][j];
    }
  }
  fr(j,n){
    k=j*x;
    fr(i,n) k+=t[i][j];
    c=min(c,k);
  }
  cout<<c<<endl;
}

Measured memory_bytes: 31744
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

/**
 * B - Mix Juice
 * ある店で N 種類の果物、果物 1,…,N が売られており、それぞれの価格は一個あたり p1,…,pN 円です。
 * この店で K 種類の果物を一個ずつ買うとき、それらの合計価格として考えられる最小の金額を求めてください。
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 入力値
        int n = sc.nextInt();   // 果物の種類
        int k = sc.nextInt();   // 購入する果物の種類

        Queue<Integer> queue = new PriorityQueue<>();
        for( int i = 0; i < n; i++ ) {
            queue.add( sc.nextInt() );
        }

        int result = 0;
        for( int i = 0; i < k; i++ ) {
            result += queue.poll();
        }

        System.out.println( result );

        sc.close();
    }
}


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    int n,x;
    cin >> n >> x;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    sort(a);
    int ans = 0;

    for(int i=0;i<n;i++){
        if(x>=a[i]){
            if(i==n-1&&x!=a[i]){
                ans--;
            }
            x-=a[i];
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
s = [input() for i in range(N)]

res = {
    'AC' : 0,
    'WA' : 0,
    'TLE' : 0,
    'RE' : 0
}

for k in s:
    res[k] = res[k] + 1

for k, v in res.items():
    print(k + ' x ' + str(v))

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


int GetDigit(int num){
    return log10(num) + 1;
}

ll get_score(vector<vector<int>>& G, vector<vector<int>>& S, int c, ll sum) {
  
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M), B(M);
  vector<ll> C(M);
  for (int i = 0; i < M; ++i) {
    ll ci;
    cin >> A.at(i) >> B.at(i) >> ci;
    C.at(i) = -ci;
  }
  ll INF = pow(10, 15);
  vector<ll> dist(N + 1, pow(10, 15));
  dist.at(1) = 0;
  for (int loop = 0; loop < N - 1; ++loop) {
    for (int i = 0; i < M; ++i) {
      if (dist.at(A.at(i)) == INF) {
        continue;
      }
      if (dist.at(A.at(i)) + C.at(i) < dist.at(B.at(i))) {
        dist.at(B.at(i)) = dist.at(A.at(i)) + C.at(i);
      }
    }
  }
  ll result = dist.at(N);
  
  vector<bool> b(N + 1, false);
  for (int loop = 0; loop < N; ++loop) {
    for (int i = 0; i < M; ++i) {
      if (dist.at(A.at(i)) == INF) {
        continue;
      }
      if (dist.at(A.at(i)) + C.at(i) < dist.at(B.at(i))) {
        dist.at(B.at(i)) = dist.at(A.at(i)) + C.at(i);
        b.at(B.at(i)) = true;
      }
      if (b.at(A.at(i))) {
        b.at(B.at(i)) = true;
      }
    }
  }
  
  if (b.at(N)) {
    cout << "inf" << endl;
  } else {
    cout << -result << endl;
  }
  return 0;
}

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

int main(){
  int n;
  std::cin >> n;
  string s = "", ss = "", r;
  string ds[] = {".", "#"};
  bool back = true;
  for (int i = 0; i < 111; i++) {
    for (int j = 0; j < 4; j++) {
      string ts, tss; 
      if(back){
        ts = s + ds[j/2], tss = ss + ds[j%2];
      }else{
        ts = ds[j/2] + s, tss = ds[j%2] + ss;
      }
      std::cout << ts << std::endl;
      std::cout << tss << std::endl;
      fflush(stdout);
      std::cin >> r;
      if(r == "T"){
        s  = ts;
        ss = tss;
        break;
      }else if(r == "F" and j == 3){
        back = false;
      }else if(r == "end"){
        i = 1e9, j = 1e9;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char c[310][310];
ll dp[101];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	ll r, g, b, n;
	cin >> r >> g >> b >> n;
	ll ans = 0;
	rep(i, n/r+1) {
		rep(j, n/g + 1) {
			ll res = n - i * r - j * g;
			if (0 <= res && res%b==0)ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vector< ll > >;
using pi = pair<ll,ll>;
using st = set<ll>;
using kiwi = queue<ll>;
using mp = map<ll,ll>;
using ump = unordered_map<ll,ll>;
#define MOD 1000000007
const ll mx = 1e5+123;
#define REP(i,n) for (ll i=1;i<=n;++i)
ll ax[mx];
inline bool isPeak(ll i){
    return (ax[i]>ax[i-1]&&ax[i]>ax[i+1]);
}
inline bool isValley(ll i){
    return (ax[i]<ax[i-1]&&ax[i]<ax[i+1]);
}
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main(){
    fastio;
    ll n, cnt=0; cin>>n;
    vi V(n+1);
    for(ll i=1;i<=n;++i){
        cin>>V[i];
        if(V[i]%2!=0&&i%2!=0) cnt++;
    }
    cout<<cnt<<endl;
return 0;
}


Measured memory_bytes: 3616
# https://atcoder.jp/contests/diverta2019-2/tasks/diverta2019_2_c

# 重要な性質: Aの各要素には好きな符号をつけるように構成できる。ただしすべて+or-はむり
# つまり負数なら-をつけ、正数ならそのまま

# 正にすべてプラスを付ける方法→負数を一つ借りて、正を引いてひって、最後に符号を逆転
# 負数に-を付ける方法→ただ引くだけで良い


# すべて負or正のときに注意して実装
N = int(input())
A = list(map(int, input().split()))

A.sort()


if A[0] >= 0:  # もし全要素が正数なら
    now = A[0]
    ansls = []
    for a in A[1:-1]:
        ansls.append((now, a))
        now = now - a

    ansls.append((A[-1], now))
    ans = A[-1] - now
    print(ans)
    for ans in ansls:
        print(*ans)
elif A[-1] <= 0:  # もし全要素が負数なら
    A = A[::-1]
    now = A[0]
    ansls = []
    for a in A[1:]:
        ansls.append((now, a))
        now = now - a

    print(now)
    for ans in ansls:
        print(*ans)
else:  # 正負が混在するならば好きに作れる
    ans = sum([abs(a) for a in A])
    print(ans)
    from bisect import bisect_right
    idx = bisect_right(A, 0) - 1  # ギリ負数を指す

    now = A[idx]
    ansls = []
    # 正の最善戦略
    for a in A[idx + 1:-1]:
        ansls.append((now, a))
        now = now - a
    ansls.append((A[-1], now))
    now = A[-1] - now  # ためていた符号大反転

    # print('-')
    # 続いて負の最善戦略
    for a in A[:idx]:
        ansls.append((now, a))
        now = now - a
    assert now == ans

    for ans in ansls:
        print(*ans)


Measured memory_bytes: 20136
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;

struct bar{
	double x1, x2, y;
	bool f;
	
	bar(double x1, double x2, double y, bool f)
		: x1(x1), x2(x2), y(y), f(f) {}
	
	bool operator<(const bar &b) const{
		return y < b.y;
	}
};

int main(){
	int n;
	double x, y, r;
	for(int number = 1; scanf("%d", &n), n != 0; ++number){
		vector<bar> bars;
		vector<double> xs;
		bars.reserve(2 * n);
		xs.reserve(2 * n);

		for(int i = 0; i < n; ++i){
			scanf("%lf%lf%lf", &x, &y, &r);
			double x1 = x - r;
			double x2 = x + r;
			
			xs.push_back(x1);
			xs.push_back(x2);
			bars.push_back( bar(x1, x2, y - r, true) );
			bars.push_back( bar(x1, x2, y + r, false) );
		}
		
		sort(xs.begin(), xs.end());
		xs.erase( unique(xs.begin(), xs.end()), xs.end() );
		sort(bars.begin(), bars.end());

		double ans = 0.0;
		for(int i = 1; i < xs.size(); ++i){
			int cnt = 0;
			double prev = 0.0;
			double len = 0.0;

			for(int j = 0; j < bars.size(); ++j){
				if( bars[j].x1 < xs[i] && bars[j].x2 >= xs[i] ){
					if( bars[j].f ){
						if( ++cnt == 1 ){
							prev = bars[j].y;
						}
					}
					else{
						if( --cnt == 0 ){
							len += bars[j].y - prev;
						}
					}
				}
			}
			
			ans += (xs[i] - xs[i-1]) * len;
		}
		
		printf("%d %.2f\n", number, ans);
	}

}

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

string S;
int main() {
  while (cin >> S) {
	if (S == "#") break;
	long long deg = 0;
	int n = 0, w = 0;
	reverse(S.begin(), S.end());
	for (int i = 0; i < S.size();) {
	  if (S.substr(i, 5) == "htron") {
		if (i != 0) deg *= 2, --deg;
		++n, i += 5;
	  }
	  else {
		deg *= 2, ++deg, ++w, i += 4;
	  }
	}
	deg *= 90;
	int num = n + w - 1;
	long long all = 1LL<<num;

	//cout << deg << ", " << all << endl;
	
	while (deg % 2 == 0 && all % 2 == 0) deg /= 2, all /= 2;
	
	if (all == 1) cout << deg << endl;
	else cout << deg << "/" << all << endl;
  }
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }

template<typename T> void remove(std::vector<T>& vector, unsigned int index)
{ vector.erase(vector.begin() + index); }


int main() {
  int a, b;  cin >> a >> b;
  if (a > b) {
    rep(i, a) {
      cout << b;
    }
    cout << endl;
  } else {
    rep(i, b) {
      cout << a;
    }
    cout << endl;
  }

  return 0;
}


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

# In[66]:


H, W = map(int, input().split())
S = [list("_"*(W+2))]
for _ in range(H):
    S.append(list("_"+input()+"_"))
S.append(list("_"*(W+2)))


# In[67]:


import copy


# In[68]:


ans = copy.deepcopy(S)
# print(ans)
for h in range(len(S)):
#     print(h)
#     print(S[h])
    for w in range(len(S[h])):
#         print(h, w, S[h][w])
        if S[h][w] == ".":
            s = S[h-1][w-1:w+2] + S[h][w-1:w+2] + S[h+1][w-1:w+2]
#             print("\t", s, s.count("#"))
            ans[h][w] = str(s.count("#"))
# print(ans)
for h in range(H):
    row = "".join(ans[h+1])
    print(row[1:-1])


# In[ ]:






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

namespace HABIT{
    #define f(a,b,c,d) for(register int a=b,c=d;a<=c;a++)
    #define g(a,b,c,d) for(register int a=b,c=d;a>=c;a--)
    #define LOCAL
    typedef int i32;
    typedef unsigned int u32;
    typedef long long int i64;
    typedef unsigned long long int u64;
    typedef pair<i32,i32> pii;
    const i32 MAXN=1e5+10;
    typedef i32 ar[MAXN];
    
    template<typename T> inline T Max(T a) { return a; }
    template<typename T,typename... Args> inline T Max(T a,Args... args){
        T b=Max(args...);
        return (a>b)?a:b;
    }
    template<typename T> inline T Min(T a) { return a; }
    template<typename T,typename... Args> inline T Min(T a,Args... args){
        T b=Min(args...);
        return (a<b)?a:b;
    }

    #ifdef LOCAL
        inline char gc() { return getchar(); }
    #else
        inline char gc() {
            static char s[1<<20|1]={0},*p1=s,*p2=s;
            return (p1==p2)&&(p2=(p1=s)+fread(s,1,1<<20,stdin),p1==p2)?EOF:*(p1++);
        }
    #endif
    inline i64 read(){
        register i64 ans=0;register char c=gc();register bool neg=0;
        while(c<48||c>57) neg^=!(c^'-'),c=gc();
        while(c>=48&&c<=57) ans=(ans<<3)+(ans<<1)+(c^48),c=gc();
        return neg?-ans:ans;
    }

    char Output_Ans[1<<20|1],*Output_Cur=Output_Ans;
    inline void output() { Output_Cur-=fwrite(Output_Ans,1,Output_Cur-Output_Ans,stdout); }
    inline void print(char c){
        if(Output_Cur-Output_Ans+1>>20) output();
        *(Output_Cur++)=c;
    }
    inline void print(char *s) { while(*s) print( *(s++) ); }
    inline void print(u64 x){
        if(!x) { print('0'); return ; }
        char buf[30]={0},*p=buf+28;
        while(x) *(p--)=x%10+48,x/=10;
        print(p+1);
    }
    inline void print(u32 x) { print( (u64)x ); }
    inline void print(i64 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
    inline void print(i32 x){
        if(x<0) print('-'),x=-x;
        print( (u64)x );
    }
}
using namespace HABIT;

priority_queue<pii> pq;
vector<i32> Edg[MAXN];
i32 N,M,Cnt,H[MAXN];
bool Vis[MAXN];

int main(){
    N=read();
    M=read();
    f(i,1,I,N) pq.push( pii(H[i]=read(),i) );
    f(i,1,I,M){
        i32 A=read(),B=read();
        Edg[A].push_back(B);
        Edg[B].push_back(A);
    }
    while( pq.size() ){
        pii tmp=pq.top();
        pq.pop();

        f(i,0,I,Edg[tmp.second].size()-1){
            Vis[ Edg[tmp.second][i] ]=1;
            if(H[ Edg[tmp.second][i] ]==H[tmp.second])
                Vis[tmp.second]=1;
        }
        
        if(!Vis[tmp.second]) Cnt++;
    }
    print(Cnt);
    output();
    return 0;
}

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

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

  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans++;
    i += k - 1;
    if (i < n - 1) i--;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
n,k=map(int, input().split())
*a,=map(int, input().split())

if k>100:
    ans=[n]*n
    print(*ans)
    exit()

for _ in range(k):
    pre_cum = [0]*(n+1)
    for i,ai in enumerate(a):
        if i-ai>=0:
            pre_cum[i-ai]+=1
        else:
            pre_cum[0]+=1
        if i+ai<n-1:
            pre_cum[i+ai+1]-=1
        else:
            pre_cum[n]-=1
    a=[]
    tmp=0
    for i in range(n):
        tmp+=pre_cum[i]
        a.append(tmp)

print(*a)


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

template <typename T>
void zero_sum_ranges(vector<T> A) {
    T n = A.size();
    T sum[n + 1] = {};
    sum[1] = A[0];
    map<T, T> mp;
    for(T i = 0; i < n; i++) {
        sum[i + 1] = (sum[i] + A[i]) % 2019;
    }
    T ret = 0;
    for(T i = 0; i <= n; i++) {
        if(mp.count(sum[i])) ret += mp[sum[i]];
        mp[sum[i]]++;
    }
    cout << ret << endl;
    // for(int i=0;i<n+1;i++){
    //     cout << sum[i] << endl;
    // }
}

int main() {
    ll n, m, i, j, k;
    string s;
    cin >> s;
    n=s.size();
    vector<ll> dp(n);
    ll cnt = 1;
    for(i=0;i<n;i++){
        dp[i]=(s[n-i-1]-'0')*cnt;
        dp[i]%=2019;
        cnt*=10;
        cnt%=2019;
    }
    zero_sum_ranges(dp);
    return 0;
}

Measured memory_bytes: 8220
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin>>N;
	LL A,B;
	LL sum = 0;
	LL MIN = INF;
	for(int i=0;i<N;++i){
		cin>>A>>B;
		sum += A;
		if( A>B ){
			MIN = min(MIN,B);
		}
	}
	LL ans = 0;
	if( MIN < INF ){
		ans = sum - MIN;
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
import collections


def calc_ans(n):
    ans = 1
    for i in range(n//2):
        ans = ans*2 % (10**9+7)
    print(ans)


n = int(input())
A = list(map(int, input().split()))

c = collections.Counter(A)

if n % 2 == 0:
    for i in range(1, n, 2):
        if c[i] != 2:
            print(0)
            break
    else:
        calc_ans(n)
else:
    for i in range(0, n, 2):
        if (i == 0 and c[i] != 1) or (i != 0 and c[i] != 2):
            print(0)
            break
    else:
        calc_ans(n)


Measured memory_bytes: 14820
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 
#define mp make_pair
#define pb push_back
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)  ((a)*((b)/gcd(a,b)))
#define pi 3.14159265358979323846
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int32_t main()
{
	reus;

//	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//	#endif
    
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int st=0,ans=1000;
    for(int i=0;i<n-1;i++)
    {
    	if(a[i]<a[i+1])
    	{
    		st=ans/a[i];
    		ans+=(st*(a[i+1]-a[i]));
		}
	}
    cout<<ans<<endl;
	return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    a--, b--, c--, d--;
    string s; cin >> s;

    for (int i = a; i < max(c, d); i++) {
        if (s[i] == '#' && s[i + 1] == '#') {
            cout << "No" << endl;
            return 0;
        }
    }
    if (c < d) {
        cout << "Yes" << endl;
        return 0;
    }
    for (int i = b - 1; i < min(d, n - 2); i++) {
        if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  int n; ll a, b;
  read(n, a, b);
  vector<ll> x(n);
  rep(i, 0, n) read(x[i]);
  ll ans = 0;
  rep(i, 0, n - 1)
    ans += min(b, a * (x[i + 1] - x[i]));
  write(ans);
}


Measured memory_bytes: 4000
#include <stdio.h>

int main(void)
{
	char s[1201];
	int i;
	fgets(s,sizeof(s),stdin);
	for(i=0;s[i]!='\0';i++){
		if('a'<=s[i]&&s[i]<='z')s[i]-='a'-'A';
		else if('A'<=s[i]&&s[i]<='Z')s[i]+='a'-'A';
	}
	printf("%s",s);
	return 0;
}



Measured memory_bytes: 2112
n, k = map(int, input().split())
#print(n, k)

ss = set()

for i in range(1, k*2+1):
  #print(i)
  if i%2==1:
    input()#print('d', i//2+1, ': ', input())
  else:
    for s_i in map(int, input().split()):
      #print('s_i: ', s_i)
      ss.add(s_i)
#print(ss)
print(len([s for s in range(1, n+1) if s not in ss]))


Measured memory_bytes: 9184
#include <iostream>
#include <vector>

int main()
{
        int n;

        std::cin >> n;

        std::vector<int> a(n);

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

        std::vector<int> b(n);
        for (int i = 0; i < n;i++) b[a[i]-1]=i+1;

        for (int i = 0; i < n; i++) std::cout << b[i] << std::endl;

        return 0;
}


Measured memory_bytes: 1536
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int M = sc.nextInt();
    int A[] = new int[M];
    int total=0;
    for(int i=0;i<M;i++){
      A[i]=sc.nextInt();

      total=total+A[i];
    }
    if(N-total>=0){
      System.out.println(N-total);
    }else{
      System.out.println(-1);
    }


  }
}
 

Measured memory_bytes: 46260
#include<iostream>

int main(){

  while(true){
    std::string str;
    std::cin >> str;
    if(str == "-") break;

    int m;
    std::cin >> m;

    int s = 0;
    for(int i = 0; i < m; i++){
      int h;
      std::cin >> h;
      s += h;
    }

    int cut = s % str.length();
    std::string shuf = str.substr(cut, str.length() - cut) + str.substr(0, cut);
    std::cout << shuf << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3148
import java.util.ArrayList;
import java.util.Scanner;
import java.util.TreeSet;

public class Main
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int r = scanner.nextInt();
		if(n >= 10)
			System.out.println(r);
		else
			System.out.println(r + 100 * (10 - n));
	}
}

Measured memory_bytes: 21844
#define    ll           long long
#define    dd           double
#define    mp           make_pair
#define    pb           push_back
#define    se           second
#define    fi           first
#define    mod          10000007
#define    sob(v)       v.begin(),v.end()
#define    sobr(v)      v.rbegin(),v.rend()
#define    fr(i,a,b)    for(int i=a;i<=b;++i)
#define    frr(i,a,b)   for(int i=a;i>=b;--i)
#define    pi           acos(-1.00)
#define    check        cout<<"*"<<endl
#define    ffix(x)      cout<<fixed<<setprecision(x)
#define    fast         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

typedef vector<int> vi;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<int,vi> pp;

int dr[4]= {0,0,-1,1};
int dc[4]= {-1,1,0,0};

const int N=100;

int main()
{
    int n;
    cin>>n;
    ll a[n+1];
    ll x=0;
    fr(i,1,n)
    {
        cin>>a[i];
        x^=a[i];
    }
    fr(i,1,n)
    {
        cout<<(a[i]^x)<<' ';
    }
    cout<<endl;
}


Measured memory_bytes: 5012
def main():
    N, K, Q = map(int, input().split())
    A_list = [int(input()) for _ in range(Q)]
    player_score = [K for _ in range(N)]

    for player_answer in A_list:
        # 正解者スコア+1して, その後全体-n
        player_score[player_answer - 1] = player_score[player_answer - 1] + 1

    player_score = list(map(lambda i: i - len(A_list), player_score))
    
    for score in player_score:
        print("Yes" if score > 0 else "No")
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 13684
#include <cstdio>
#include <algorithm>
 
using namespace std;
 
int main(){
 
int a,b,c,d,e;
 
scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
 
int aa = min(a,min(b,c));
 
int bb = min(d,e);
 
printf("%d\n",aa+bb-50);
return 0;
 
}


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
using namespace std;
int main()
{
    fastio;
    long long n,k,i,j,mn=INT_MAX;
    cin>>n>>k;
    long long a[n],dp[k+1];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        mn=min(mn,a[i]);
    }
    for(i=0; i<=k; i++)
    {
        bool flag=false;
        if(i<mn)
        {
            dp[i]=0;
        }
        else
        {
            for(j=0; j<n; j++)
            {
                if(i-a[j]>=0 && dp[i-a[j]]==0)
                {
                    flag=true;
                    dp[i]=1;
                    break;
                }
            }
            if(flag==false)
            {
                dp[i]=0;
            }
        }
    }
    if(dp[k]==1)
    {
        cout<<"First";
    }
    else
    {
        cout<<"Second";
    }
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int,input().split()))
a.insert(0,0)
ans = 0
for i in range(1,n+1):
    ans += abs(a[i-1]-a[i])
ans += abs(a[-1])
for i in range(1,n):
    print(ans - (abs(a[i-1]-a[i]) + abs(a[i]-a[i+1])) + (abs(a[i-1]-a[i+1])))
print(ans - (abs(a[-2]-a[-1]) + abs(a[-1])) + (abs(a[-2])))

Measured memory_bytes: 20636
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
//priority_queue<long long, vector<long long>, greater<long long>> pq;

const double TL = 1.5 * CLOCKS_PER_SEC;
mt19937 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
#define clr(x, y) memset(x, y, sizeof(x))
#define forn(i, n) for (int i = 0; i < n; i++)
#define LL long long
const double pi = acos(-1.0);


int n, k;
int a[1000];

int main() {
  //auto start_clock = clock();
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) {
    int d;
    scanf("%d", &d);
    for (int j = 0; j < d; j++) {
      int x;
      scanf("%d", &x);
      a[x] += 1;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] == 0) {
      ans += 1;
    }
  }
  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define inf (int)1e7
using namespace std;

struct data {
  int x, y, c;
};

long long h, w;
int d[4] = {0, 1, 0, -1};
vector<string> s;
vector<vector<int>> dis;

bool isvalid(const data &now) {
  return now.x >= 0 && now.x < h && now.y >= 0 &&
         now.y < w && s[now.x][now.y] == '.';
}
long long solve();

int main() {
  cin >> h >> w;
  s.resize(h);
  for(int i = 0; i < h; ++i) cin >> s[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long res = -1;
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j)
      for(int k = 0; k < h; ++k)
        for(int l = 0; l < w; ++l) {
          data st = {i, j, 0}, go = {k, l, 0};
          if(!isvalid(st) || !isvalid(go)) continue;
          queue<data> qu;
          dis.assign(h, vector<int>(w, inf));
          dis[i][j] = 0;
          qu.push(st);
          while(!qu.empty()) {
            data now = qu.front();
            qu.pop();
            for(int m = 0; m < 4; ++m) {
              data nextp = now;
              nextp.x += d[m];
              nextp.y += d[m ^ 1];
              ++nextp.c;
              if(isvalid(nextp) &&
                 dis[nextp.x][nextp.y] > nextp.c) {
                dis[nextp.x][nextp.y] = nextp.c;
                qu.push(nextp);
              }
            }
          }
          res = max(res, (long long)dis[k][l]);
        }
  return res;
}

Measured memory_bytes: 256
let rec take l n = if n == 0 then [] else match l with
    | [] -> []
    | (x::xs) -> x :: take xs (n-1)

let () =
    let rec read n ls = match n with
        | 0 -> ls
        | otherwise -> begin
            let s = read_line () in
            let x = int_of_string s in
            read (n-1) (x :: ls)
        end
    in
    let data = read 10 [] in
    let sorted = (List.sort compare data) in
    let taken = take (List.rev sorted) 3 in 
    List.iter (Printf.printf "%d\n") taken

Measured memory_bytes: 2140
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>

using namespace std;

void solve(long long N, vector<long long> A){
    vector<long long> cumsum(N+1);
    cumsum[0] = 0;
    for (int i = 0; i < N; i++) {
        cumsum[i+1] = cumsum[i] + A[i];
    }
    long long ret = numeric_limits<long long>::max()/4;
    for (int i = 2; i < N-1; i++) {
        long long lsum = cumsum[i] - cumsum[0];
        long long rsum = cumsum[N] - cumsum[i];
        int ldiv = lower_bound(cumsum.begin(), cumsum.end(), lsum/2) - cumsum.begin();
        long long b, b1, b2, c, c1, c2;
        b1 = cumsum[ldiv] - cumsum[0];
        b2 = cumsum[min(ldiv-1, (int)i)] - cumsum[0];
        c1 = cumsum[i] - cumsum[ldiv];
        c2 = cumsum[i] - cumsum[min(ldiv-1, (int)i)];
        if (c2 - b2 > b1 - c1) {
            b = b1;
            c = c1;
        } else {
            b = b2;
            c = c2;
            ldiv--;
        }
        int rdiv = lower_bound(cumsum.begin(), cumsum.end(), cumsum[i] + rsum/2) - cumsum.begin();
        long long d, d1, d2, e, e1, e2;
        d1 = cumsum[rdiv] - cumsum[i];
        d2 = cumsum[min(rdiv-1, (int)N)] - cumsum[i];
        e1 = cumsum[N] - cumsum[rdiv];
        e2 = cumsum[N] - cumsum[min(rdiv-1, (int)N)];
        if (e2 - d2 > d1 - e1) {
            d = d1;
            e = e1;
        } else {
            d = d2;
            e = e2;
            rdiv--;
        }
        long long mini = min(min(b, c), min(d, e));
        long long maxi = max(max(b, c), max(d, e));
        ret = min(ret, maxi - mini);
    }
    std::cout << ret << std::endl;
}

int main(){
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    long long N;
    scanf("%lld",&N);
    vector<long long> A(N-1+1);
    for(int i = 0 ; i <= N-1 ; i++){
    	scanf("%lld",&A[i]);
    }
    solve(N, A);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, K;
int A[2010], B[2010];
vector<int> tree[2010];
int dis[2010];

void rec(int v, int pv, int lev) {
  dis[v] = lev;
  for (int nv : tree[v]) {
    if (nv == pv) continue;
    rec(nv, v, lev+1);
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> K;
  for (int i = 0; i < N-1; i++) {
    cin >> A[i] >> B[i];
    A[i]--; B[i]--;
    tree[A[i]].emplace_back(B[i]);
    tree[B[i]].emplace_back(A[i]);
  }
  int ans = N;
  if (K % 2 == 0) {
    for (int i = 0; i < N; i++) {
      rec(i, -1, 0);
      int cnt = 0;
      for (int j = 0; j < N; j++) {
        cnt += dis[j] > K / 2;
      }
      ans = min(ans, cnt);
    }
  } else {
    for (int i = 0; i < N-1; i++) {
      rec(A[i], B[i], 0);
      rec(B[i], A[i], 0);
      int cnt = 0;
      for (int j = 0; j < N; j++) {
        cnt += dis[j] > (K-1) / 2;
      }
      ans = min(ans, cnt);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define INF 1000000007
#define SEP " "

int     main()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == 0)
		{
			cout << 0 << endl;
			return (0);
		}
	}
	ll ans = 1;
	bool f = false;
	ll lim = pow(10, 18);
	for (int i = 0; i < n; i++) {
		if (a[i] != 0 && lim / a[i] < ans)
		{
			f = true;
			break;
		}
		ans *= a[i];
	}
	if (f)
		cout << -1 << endl;
	else
		cout << ans << endl;
}


Measured memory_bytes: 3972
#include <stdio.h>
int main(void){
   int i,j,H,W;
   while(1){
       scanf("%d %d",&H,&W);
       if(H==0&&W==0) break;
       for(j=1;j<=H;j++){
           for(i=1;i<=W;i++){
               putchar('#');
           }
           printf("\n");
       }
       printf("\n");
   }
   return 0;  
}


Measured memory_bytes: 2556
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

map<P, ll> mp;

ll f(ll i, ll x) {
  if(x <= 0 || i < 0) return 0;
  if(i == 0) return 1;
  if(mp.count({i, x})) return mp[{i, x}];
  ll a = (1LL << (i + 1)) - 3;
  ll res;
  if(x == 1)
    res = 0;
  else if(x < a + 2)
    res = f(i - 1, x - 1);
  else
    res = f(i - 1, a) + f(i - 1, x - a - 2) + 1;
  mp[{i, x}] = res;
  return res;
}

int main() {
  ll n, x;
  cin >> n >> x;
  cout << f(n, x) << endl;
}

Measured memory_bytes: 3692
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define max(a,b) a<b?b:a
#define min(a,b) a<b?b:a
 
typedef struct POINT{
    double x,y;
}POINT;
typedef struct LINE{
    double x,y;
}LINE;
 
//double 
 
double dot(POINT a,POINT b){//??????
    return a.x*b.x + a.y*b.y;
}
double cross(POINT a,POINT b){//??????
    return a.x*b.y - a.y*b.x;
}
POINT make_vec(POINT a,POINT b){//a->b
    b.x -= a.x;
    b.y -= a.y;
    return b;
}
 
int inclusion(POINT a[],int n,POINT p){
    int ans = 0;
    int i;
    POINT g[n+1];
    double w,rad = 0.0;
 
    for(i = 0;i < n;i++){
        g[i] = a[i];
    }
    g[n] = g[0];
 
    for(i = 0;i < n;i++){
        if(fabs(g[i].x - p.x)<=0.000001 && fabs(g[i].y - p.y) <= 0.000001){
            return ans = 1;
        }
    }
    for(i = 0;i < n;i++){
        w = atan2(cross(make_vec(p,g[i]),make_vec(p,g[i+1])),
                dot(make_vec(p,g[i]),make_vec(p,g[i+1])));
        rad += w;
        if(fabs(w - 3.1415926535) <= 0.000001 ||
             fabs(w + 3.1415926535) <= 0.000001)
            return ans = 1;
    }
    if(fabs(rad - 3.1415926535*2)<=0.000001){//2??
        return ans = 2;//in!
    }
    return ans;
}
 
int main(){
    int i,m,n;
    POINT g[100];//n
    POINT q;//m
    int ans = 0;
 
    scanf("%d",&n);
    for(i = 0;i < n;i++){
        scanf("%lf%lf",&g[i].x,&g[i].y);
    }
    scanf("%d",&m);
    for(i = 0;i < m;i++){
        scanf("%lf%lf",&q.x,&q.y);
        ans = inclusion(g,n,q);
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 724
#include <iostream>
#include <cstdio>
#include <algorithm>

#define ll unsigned long long int
#define abs(N) (((N)>0)?(N):(-1)*(N))

using namespace std;

int n;

ll calc(int * a){
	ll sum=0;

	for (int i = 0; i < n-1; ++i) {
		int d = a[i+1]-a[i];
		sum += abs(d);
	}

	return sum;
}

int main() {
	cin >> n;

	int a[n],b[n],c[n];
	ll sb,sc,smax=0;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	sort(a,a+n);

	for (int i = 0; i < n; ++i) {
		int j;
		if(i%2==0){
			j = n-1-i/2;
		}else{
			j = (i-1)/2;
		}
		b[i] = a[j];
		c[(i+1)%n]=a[j];
	}
	sb = calc(b);
	sc = calc(c);
	smax =  (sb>sc)?sb:sc;

	for (int i = 0; i < n; ++i) {
		int j;
		if(i%2==0){
			j = i/2;
		}else{
			j = n - 1 - (i-1)/2 ;
		}
		b[i] = a[j];
		c[(i+1)%n]=a[j];
	}
	sb = calc(b);
	sc = calc(c);
	if(sb>smax)smax = sb;
	if(sc>smax)smax = sc;


	cout << smax << endl;



	return 0;
}


Measured memory_bytes: 1408
n,s = map(int,input().split())
A = list(map(int,input().split()))

mod = 998244353

dp = [[0]*(s+1) for _ in range(n+1)]
dp[0][0] = 1
# dp[i][j] = iこめまで見てS=jのときのans
for i,a in enumerate(A):
    for j in range(s+1):
        dp[i+1][j] += dp[i][j]*2%mod
        dp[i+1][j] %= mod
        if j+a <= s:
            dp[i+1][j+a] += dp[i][j]
            dp[i+1][j+a] %= mod
print(dp[n][s]%mod)


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

int n, k, m = 0;
int l[10], r[10], a[200001];
const int M = 998244353;

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

	for (int i = 0; i < k; i++)
		cin >> l[i] >> r[i];

	a[1] = 1;
	a[2] = -1;

	for (int i = 1; i <= n; i++) {
		m = (m + a[i]) % M;

		for (int j = 0; j < k; j++) {
			if (i + l[j] <= n)
				a[i + l[j]] = (a[i + l[j]] + m) % M;

			if(i + r[j] + 1 <= n)
				a[i + r[j] + 1] = (M + a[i + r[j] + 1] - m) % M;
		}
	}		

	cout << m << endl;
}


Measured memory_bytes: 4392
from collections import Counter

n = int(input())
letters = [input() for _ in range(n)]

cnt = Counter(letters[0])

for i in range(1,n):
    cnt = cnt & Counter(letters[i])

int_list = sorted(cnt.items(), key=lambda x:x[0])

ans = ""
for key, val in int_list:
    ans += key*val
print(ans)

Measured memory_bytes: 3564
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	K := getInt()
	n := 50
	x := (n - 1) + K/n - K%n
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = x
	}

	for i := 0; i < K%n; i++ {
		a[i] += n + 1
	}
	out(n)
	for i := 0; i < n; i++ {
		fmt.Print(a[i], " ")
	}
	out()

}


Measured memory_bytes: 1760
#include <bits/stdc++.h>
using namespace std;
 
 
#define FAST std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M 1000000007
#define mp make_pair
#define pb push_back
#define PB pop_back
#define sl(a) (int)a.length()
#define sz(a) (int)a.size()
#define lcase(a) (char)tolower(a)
#define ucase(a) (char)toupper(a)
#define precise(a) fixed<<setprecision(a)<<
#define F first
#define S second
#define I insert
#define pii pair<int,int>
#define trav(a, x) for(auto& a : x)
#define fl(i,n) for(int i = 0;i<n;i++)
#define rfl(n) for(int i = n-1;i>=0;i--)
#define time cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.I(tmp);commands}
#define display(x) trav(a,x) cout<<a<<" "; cout<<endl;
#define ingrid(data,n,commands) for(int i = 0; i<n; i++){cin>>data[i];commands}
#define section(a,b,w) set_intersection(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define union(a,b,w) set_union(a.begin(), a.end(),b.begin(), b.end(),back_inserter(w));
#define copy(a,w) copy(a.begin(), a.end(),back_inserter(w));
#define all(data) data.begin(), data.end()
#define PI 3.14159265358979323844
#define endl '\n'
#define last(a) a[sz(a)-1]
#define mp make_pair
 
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
 
// Graph DFS
const int fx[]={+1,-1,+0,+0};
const int fy[]={+0,+0,+1,-1};
 
//primes for hashing 937,991,1013,1409,1741
 
//Returns index of first element not less than key and more than key respectively
#define lb(data,key) lower_bound(all(data),key) - data.begin();
#define up(data,key) upper_bound(all(data),key) - data.begin();
#define fnd(data,key) find(all(data),key) - data.begin();
//Long Long Int
#define int long long int

void solve()
{
    int n;cin>>n;
    std::vector<int> v;
    fl(i,n)
    {
        int j;cin>>j;
        v.pb(j);
    }
    int dp[n];
    dp[n-1]=0;
    for(int i=n-2;i>=0;i--)
    {
        dp[i]=abs(v[i]-v[i+1])+dp[i+1];
        if(i+2<=n-1)
            dp[i]=min(dp[i],abs(v[i]-v[i+2])+dp[i+2]);
    }
    cout<<dp[0]<<endl;
}
 
signed main()
{
    
    FAST
    
    int t = 1;
    //cin>>t;
    while(t--)
    solve();
    
 
return 0;
}
 
/*6
30 10 60 10 60 50*/

Measured memory_bytes: 1908
#include <cstdio>
#include <stack>
#include <algorithm>
using namespace std;

int main()
{
    int T, D, L, wave, cnt, global_max, current_max;
    for (; ; ) {
        scanf("%d %d %d", &T, &D, &L);
        if (T == 0 && D == 0 && L == 0) break;
        cnt = global_max = current_max = 0;
        for (int i = 0; i < T; i++) {
            scanf("%d", &wave);
            if (wave >= L) {
                if (cnt < 0) current_max = 1;
                else current_max++;
                cnt = D;
            }
            else {
                cnt--;
                if (cnt > 0) current_max++;
                if (cnt == 0) global_max = max(global_max, current_max);
            }
        }
        if (current_max > 0) global_max = max(global_max, current_max-1);
        printf("%d\n", global_max);
    }

    return 0;
}



Measured memory_bytes: 2732
#include<bits/stdc++.h>
using namespace std;
bool checkValidity(int a, int b, int c) 
{ 
    // check condition 
    if (a + b <= c || a + c <= b || b + c <= a) 
        return false; 
    else
        return true; 
} 
int main(int argc, char const *argv[])
{
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	int count = 0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				if(a[i]==a[j])continue;
				if(a[j]==a[k])continue;
				if(a[k]==a[i])continue;
				if(checkValidity(a[i],a[j],a[k])){
					count +=1;
					// cout <<a[i]<<" "<<a[j]<<" "<<a[k]<<endl;
				}
			}
		}
	}
	cout<< count<<endl;
	return 0;
}

Measured memory_bytes: 3628
import java.util.*;

 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] L = new int[N];
		int count = 0;

		for(int i = 0; i < N; i ++){
			L[i] = sc.nextInt();
		}
		

		for(int i = 0; i < N; i ++){
			for(int j = i + 1; j < N; j ++){
				for(int k = j + 1; k < N; k ++){
					if((L[i] != L[j] && L[j] != L[k] && L[i] != L[k]) && ((L[i] < L[j] + L[k]) && (L[j] < L[i] + L[k]) && (L[k] < L[i] + L[j])) ){
						count ++;
					}
				}
			}
		}

			System.out.println(count);

	}
}

Measured memory_bytes: 37132
#include<iostream>
#include<cmath>
main(){
for(double r,i,j;std::cin>>r,r;printf("%.0f/%.0f\n",j,i)){
 for(i=0;++i<100000;){
  j=(int)(i*M_PI);
  if(fabs(j/i-M_PI)<=r||fabs(++j/i-M_PI)<=r)break;
 }
}}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    
        var sc = new Scanner(System.in);
    
        int x = Integer.parseInt(sc.next());
        
        if(x >= 30){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35560
from collections import deque

s = input()
n = int(input())
a = deque()
b = deque()
reverse_flag = False

for i in range(n):
    command = input()
    # reverse
    if len(command) == 1:
        reverse_flag = not reverse_flag
    
    else:
        _, t, f = command.split(' ')
        if t == '1':
            if reverse_flag:
                b.append(f)
            else:
                a.appendleft(f)
        else:
            if reverse_flag:
                
                a.appendleft(f)
            else:
                b.append(f)

a = list(a)
b = list(b)
if reverse_flag:
    print(''.join(b[::-1]) + s[::-1] + ''.join(a[::-1]))
else:
    print(''.join(a) + s + ''.join(b))

Measured memory_bytes: 66136
#include <iostream>
#include <map>
#include <utility>
#include <string>

using namespace std;

int main(){
    int n,m,num;
    int ac = 0,w = 0;
    int wa[100000] = {0};
    bool flag[100000] = {false};
    
    string s;

    cin >> n >> m;

    for(int i = 0;i < m;i++){
        cin >> num >> s;
        
        if(flag[num-1] == false){
            if(s == "AC"){
                ac++;
                flag[num-1] = true;
                w += wa[num-1];
            }else if(s == "WA"){
                wa[num-1]++;
            }
        }
     
    }

    cout << ac << " " << w << endl;

    return 0;


}

Measured memory_bytes: 768