akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  startupcpp();
  int i,j,k,H,W,x,front;
  cin>>H>>W;
  vector<vector<int>> v(H,vector<int>(W));
  rep(i,H){
    rep(j,W)cin>>v[i][j];
  }
  rep(i,H){
    rep(j,W){
      cin>>x;
      v[i][j]-=x;
    }
  }
  front=15000;
  vector<vector<vector<bool>>> g(H,vector<vector<bool>>(W,vector<bool>(front*2,0)));
  g[0][0][front+v[0][0]]=true;
  g[0][0][front-v[0][0]]=true;
  rep(i,H){
    rep(j,W){
      if(j){rep(k,front*2){if(g[i][j-1][k]){
        g[i][j][k+v[i][j]]=true;
        g[i][j][k-v[i][j]]=true;
      }}}
      if(i){rep(k,front*2){if(g[i-1][j][k]){
        g[i][j][k+v[i][j]]=true;
        g[i][j][k-v[i][j]]=true;
      }}}
    }
  }
  x=front;
  rep(i,front*2)if(g[H-1][W-1][i])chmin(x,abs(front-i));
  cout<<x<<endl;
  return 0;
}

Measured memory_bytes: 24320
#include <iostream>

using namespace std;

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

    if (a > 12)
    {
        cout << b << endl;
    }
    else if (a >= 6 && a <= 12)
    {
        cout << b / 2 << endl;
    }
    else
    {
        cout << 0 << endl;
    }
    
    return 0;
}

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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a1(n), a2(n);
	for (auto&& ai : a1) cin >> ai;
	for (auto&& ai : a2) cin >> ai;
	int maxcandies = a1[0];
	for (auto&& ai : a2) maxcandies += ai;

	int candies = maxcandies;
	for (int i = 1; i < n; i++)
	{
		candies += a1[i] - a2[i-1];
		maxcandies = max(maxcandies, candies);
	}
	cout << maxcandies << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n,a,saisyou=1000000,saidai=-1000000;
	long goukei=0;
	scanf("%d",&n);
	while(n>0){
	scanf("%d",&a);
	if(a<saisyou) saisyou=a;
	if(a>saidai) saidai=a;
	goukei+=a;
	n--;
	}
	printf("%d %d %ld\n",saisyou,saidai,goukei);
	return 0;
}

Measured memory_bytes: 600
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        int n;
        int m;

        boolean border(int x, int y) {
            return x >= 0 && x < n && y >= 0 && y < m;
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            n = in.nextInt();
            m = in.nextInt();
            int q = in.nextInt();

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

            int[][] g = new int[n][m];
            int cur = 0;
            int x = 0, y = 0;
            for (int k = 0; k < q; ++k) {
                int p = in.nextInt();
                while (p-- > 0) {
                    g[x][y] = k + 1;
                    if (!border(x + dx[cur], y + dy[cur]) || g[x + dx[cur]][y + dy[cur]] > 0) {
                        cur = (cur + 1) % 4;
                    }

                    x += dx[cur];
                    y += dy[cur];
                }
            }
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) {
                    out.print(g[i][j] + " ");
                }
                out.println();
            }
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23764
import java.io.BufferedReader; 
import java.io.*;
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 
import java.util.*;
import java.math.*;
public class Main 
{ 
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader()
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next()
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine();
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
  static int gcd(int a,int b)
    {
        if(a==0)
            return b;
        return gcd(b%a,a);
    }

    public static void main(String[] args) {
        FastReader sc=new FastReader();
        PrintWriter pw = new PrintWriter(System.out);
        int test = 1;//sc.nextInt();
        while(test-- > 0)
        {
            int n = sc.nextInt();
            Set<Integer> hs=new HashSet<>();
            for(int i=0;i<n;i++) hs.add(sc.nextInt());
            if(hs.size()==n)
            pw.println("YES");
            else pw.println("NO");
        }
        pw.close();
    }
}
  

Measured memory_bytes: 59044
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main() {
	std::vector<int> a(4);
	for(int i = 0; i < 4; i++) cin >> a[i];
	sort(begin(a), end(a));
	
	if(a[0] == a[1] and a[2] == a[3]) cout << "yes" << endl;
	else cout << "no" << endl;
	return 0;
}



Measured memory_bytes: 3168
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner stdin = new Scanner(System.in);
		String data = null;
		String[] bmi = new String[3];
		double BMI = 0.0;
		Arrays.fill(bmi, null);

		while(stdin.hasNext()) {

			data = stdin.next();
			bmi = data.split(",");
			BMI = Double.parseDouble(bmi[1]) / (Double.parseDouble(bmi[2]) * Double.parseDouble(bmi[2]));
			if(BMI >= 25) {
				System.out.println(bmi[0]);
			}

		}

	}

}

Measured memory_bytes: 26032
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e12;
const int MOD=1e9+7;
const double pi=acos(-1);

int main(){
  ll n;
  cin >> n;
  vector<ll>name(5,0);
  rep(i,n){
    string s;
    cin >> s;
    if(s[0]=='M')name[0]++;
    if(s[0]=='A')name[1]++;
    if(s[0]=='R')name[2]++;
    if(s[0]=='C')name[3]++;
    if(s[0]=='H')name[4]++;
  }
  ll ans=0;
  rep(i,3){
    for(int j=i+1;j<4;j++){
      for(int k=j+1;k<5;k++){
        ans+=name[i]*name[j]*name[k];
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T,typename U>bool chmin(T& a,const U& b){return a>b?(a=b,1):0;}
template<typename T,typename U>bool chmax(T& a,const U& b){return a<b?(a=b,1):0;}

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

	for(int a,b;cin>>a>>b&&a|b;){
		int d=b-a;
		int h=d*(d+1)/2;
		cout<<h-b<<endl;
	}
}


Measured memory_bytes: 256
N,M = map(int,(input().split()))
A = list(map(int,input().split()))

cost = sorted(list(zip([[2,5,5,4,5,6,3,7,6][a-1] for a in A],A)),key = lambda x: (x[0],-x[1]))

#同じ画数の数字を除く
tmp = len(cost)
i = 1
while i < tmp:
    if cost[i][0] == cost[i-1][0]:
        cost.pop(i)
        tmp = len(cost)
    else:
        i += 1
cost.sort(key = lambda x:-x[1])

dp = [0]+[-10]*(N)
for i in range(2,N+1):
    dp[i] = max([-10]+[dp[i-a]+1 for a,_ in cost if i >= a])

n = N
out = ""
i = 0
while n:
    c , a = cost[i]
    if (n>=c) and (dp[n-c] == dp[n]-1):
        n -= c
        out += str(a)
    else:
        i+=1
print(out)

Measured memory_bytes: 3440
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

vector<int> L[200005];
int n, D, nr, nodMax, uz[200005], dp[200005];

void DFS(int x);

int main()
{
    int x, y;

    cin >> n;
    for (int i=1;i<n;i++)
    {
        cin >> x >> y;
        L[x].push_back(y);
        L[y].push_back(x);
    }
    DFS(1);
    memset(uz,0,sizeof(uz));
    DFS(nodMax);
    dp[0] = 1;
    dp[1] = 0;
    for (int i=2;i<=D;i++)
        dp[i] = (dp[i-2] == 0 || dp[i-1] == 0);
    if (dp[D])
        cout << "First\n";
    else
        cout << "Second\n";
    return 0;
}

void DFS(int x)
{
    uz[x] = 1;
    if (nr > D)
    {
        D = nr;
        nodMax = x;
    }
    for (int i:L[x])
    {
        if (!uz[i])
        {
            nr++;
            DFS(i);
            nr--;
        }
    }
}

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

int main() {
    string o,e;
    cin >> o >> e;
    rep(i,e.size()) cout << o[i] << e[i];
    if(o.size() > e.size()) cout << o[o.size()-1];
    cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int a, b, c;
  int temp;

  scanf("%d %d %d", &a, &b, &c);

  if(a > b){
    temp = a;
    a = b;
    b = temp;
  }

  if(b > c){
    temp = b;
    b = c;
    c = temp;
  }

  if(a > b){
    temp = a;
    a = b;
    b = temp;
  }

  printf("%d %d %d\n", a, b, c);

  return 0;
}

Measured memory_bytes: 596
dic = {"r":1,"g":2,"b":3}
rgb = ["r","g","b"]
while 1:
	worm = raw_input()
	if worm == "0": break
	n = len(worm)
	ref = ["r"*n,"g"*n,"b"*n]
	cnt = flag = 0
	queset = set([worm])
	done = set()
	while 1:
		que = list(queset)
		queset = set()
		for Worm in que:
			if Worm in ref:
				flag = 1
				break
			for i in range(n-1):
				if Worm[i] != Worm[i+1]:
					nextclr = rgb[5-dic[Worm[i]]-dic[Worm[i+1]]]
					queset.add(Worm[:i] + 2*nextclr + Worm[i+2:])
		if flag or cnt > 14: break
		cnt += 1
		queset -= done
		done |= queset
	print cnt if flag else "NA"

Measured memory_bytes: 6216
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int ans = 100000000;

int main(){
    vector<vector<int>> c(3,vector<int>(3));
    rep(i,3){
        rep(j,3){
            cin >> c[i][j];
        }
    }
    for (int a1 = 0; a1 <= 100; a1++){
        int b1 = c[0][0] - a1;
        int b2 = c[0][1] - a1;
        int b3 = c[0][2] - a1;
        int a2 = c[1][0] - b1;
        int a3 = c[2][0] - b1;
        
        vector<int> a = {a1,a2,a3};
        vector<int> b = {b1,b2,b3};

        bool isOK = true;
        rep(i,3){
            rep(j,3){
                if (c[i][j] != a[i]+b[j]){
                    isOK = false;
                }
            }
        }
        if (isOK){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3640
// B.

#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	bool ans = false;
	for (int i = 0; i <= 100; ++i) {
		for (int j = 0; j <= 100; ++j) {
			if (i * 4 + j * 7 == n) {
				ans = true;
			}
		}
	}
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll N;
    cin >> N;
    map<string, ll> mp;
    ll cnt = 0;
    rep(i, N) {
        string s;
        cin >> s;
        mp[s]++;
        chmax(cnt, mp[s]);
    }

    vector<string> ans;
    for(auto p : mp) {
        if (p.second == cnt) ans.emplace_back(p.first);
    }
    sort(ans.begin(), ans.end());
    for(auto s : ans) cout << s << endl;
}

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

int main(){
	int x;
  	string y;
  	cin>>y;
  	x=700;
  	if(y[0]=='o')x=x+100;
  	if(y[1]=='o')x=x+100;
  	if(y[2]=='o')x=x+100;
  	cout << x << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#pragma GCC optimize("O2")
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int MOD=1e9+7;
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline int Mult(int x,int y){long z=x*y-(long)((long double)x/MOD*y+1e-8)*MOD;return z;}
static inline void Radix(int A[],const int N)
{
  int temp[200001];
  rep(k,4)
  {
    int u[256]={},v[256]={};
    rep(i,N)u[A[i]>>8*k&255]++;
    rep(i,255)u[i+1]+=u[i];
    rep(i,N){temp[--u[A[N-1-i]>>8*k&255]]=A[N-1-i];}k++;
    rep(i,N)v[temp[i]>>8*k&255]++;
    rep(i,255)v[i+1]+=v[i];
    rep(i,N)A[--v[temp[N-1-i]>>8*k&255]]=temp[N-1-i];
  }
}
int main()
{
  int N=IN(),K=IN(),m=0,p=0,z=0,accum=1,A[200000];
  rep(i,N){A[i]=IN();if(A[i]>0)p++;else if(A[i]<0)m++;else z++;}
  Radix(A,N);
  if(K==N){if(z){return puts("0"),0;}else{rep(i,K){accum=Mult(accum,A[i]);}K=0;}}
  if(m+p<K)return puts("0"),0;
  if(!p&&K&1){if(z){return puts("0"),0;}else rep(i,K){accum=Mult(accum,A[N-1-i]);}K=0;}
  p+=z,m=p;
  if(K&1){K--;accum=Mult(accum,A[--p]);}
  while(K)
  {
    K-=2;
    if(p>=2&&m<=N-2&&1l*A[p-1]*A[p-2]>1l*A[m]*A[m+1]){accum=Mult(Mult(accum,A[p-1]),A[p-2]),p-=2;continue;}
    if(p>=2&&m<=N-2&&1l*A[p-1]*A[p-2]<1l*A[m]*A[m+1]){accum=Mult(Mult(accum,A[m]),A[m+1]),m+=2;continue;}
    if(p>=2){accum=Mult(Mult(accum,A[p-1]),A[p-2]),p-=2;continue;}
    if(m<=N-2){accum=Mult(Mult(accum,A[m]),A[m+1]),m+=2;continue;}
  }
  return printf("%d\n",accum<0?accum+MOD:accum),0;
}

Measured memory_bytes: 3156
import java.io.*;
import java.util.Scanner;


public class Main {
    public static void main(String[] args)throws Exception{
        Scanner scan = new Scanner(System.in);
        int n =scan.nextInt();
        String st = "";
        for(int i = 0;i <= n - 1;i++){
            //3の倍数
            if((i + 1) % 3 == 0){
                st += " " + (i + 1);
            }
            //1の位が3
            else if((i + 1) % 10 == 3){
                st += " " + (i + 1);
            }
            //10の位が3
            else if((i + 1) % 100 >= 30 && (i + 1) % 100 <= 39){
                st += " " + (i + 1);
            }
            //100の位が3
            else if((i + 1) % 1000 >= 300 && (i + 1) % 1000 <= 399){
                st += " " + (i + 1);
            }
            //1000の位が3
            else if((i + 1) % 10000 >= 3000 && (i + 1) % 10000 <= 3999){
                st += " " + (i + 1);
            }
        }
        System.out.println(st);
    }
}


Measured memory_bytes: 184724
N, M = [int(n) for n in input().split()]
solved = {}
result = {}

for i in range(M):
    p, S = input().split()
    status = result.setdefault(p, [])
    if len(status)==0:
        result[p] = []
        solved[p] = False
    if S == 'AC':
        solved[p] = True
    result[p].append(S)

ans = 0
wa = 0
for k, v in solved.items():
    if v:
        ans += 1
        wa += result[k].index('AC')
print(ans , wa)


Measured memory_bytes: 41328
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))

const int inf = 999999999;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int a[35][200010];
int sum[200010], k[200010];

int main(){
	int n, C; cin >> n >> C;
	int s[n], t[n], c[n];
	Rep(i, n){
		cin >> s[i] >> t[i] >> c[i];
	}
	For(i, 1, C + 1) {
		Rep(j, 200010) k[j] = 0;
		Rep(j, n) if(c[j] == i) k[s[j] * 2 - 1]++, k[t[j] * 2]--;
		For(j, 1, 200010) k[j] += k[j - 1];
		Rep(j, 200010) if(k[j] > 0) sum[j]++;
	}
	int ans = -inf;
	Rep(i, 200010) ans = max(ans, sum[i]);
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main(){
    vector<int> hello;
    int n;
    cin >> n;
    for(int i =0; i< n;i++){
        int u;
        cin >> u;
        hello.push_back(u);
    }
    int ans=0;
    int track = 0;
    int cur = 0;
    while(cur < hello.size()){
        track = 0;
        for(int j =cur;j<n-1;j++){
            if(hello[j]>=hello[j+1]){
                track+=1;
            }
            else{
                break;
            }
        }
        cur = cur+track+1;
        if(track > ans){
            ans = track;
        }
    }
    cout << ans;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
#define FOR(i, a) for(int i = 0; i < (a); ++i)

ll MOD = 1e9 + 7;

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll h, w;
    cin >> h >> w;
    vector<string> grid;
    vector<vector<ll>> dp (h, vector<ll>(w, 0));
    FOR(i, h)
    {
        string s;
        cin >> s;
        grid.push_back(s);
    }
    dp[0][0] = 1;
    FOR(i, h)
    {
        FOR(j, w)
        {
            if(grid[i][j] == '#') continue;
            if(i - 1 >= 0) dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
            if(j - 1 >= 0) dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
        }
    }
    cout << (dp[h - 1][w - 1] % MOD);
    return 0;
}

Measured memory_bytes: 9216
const double = Float64
const int = Int64
const vint = Vector{int}
const vdouble = Vector{double}

int(x) = parse(int,x)

parseint(x) = parse(int, x)
readint() = map(parseint, split(readline()))

function main()
  x = readint()[1]
  for a in -120:120, b in -120:120
    if a^5 - b^5 == x
      println(a," ",b)
      return
    end
  end

end

main()

Measured memory_bytes: 215260
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let [n;l] = reads int
    let ps = List.map (fun i -> l + i - 1) [1..n]
    let q :: qs = List.sortBy abs ps
    printfn "%i" (List.sum qs)
    0

Measured memory_bytes: 14940
#include "bits/stdc++.h"
using namespace std;
const int N = 1e3 + 3;
const int mod = 1e9 + 7;
int n , a , b , c , d;
inline int add(int a , int b){
    return (a + b) % mod;
}
inline int mult(int a , int b){
    return (1LL * a * b) % mod;
}
int power(int a , int b){
    int res = 1;
    while(b){
        if(b & 1){
            res = mult(res , a);
        }
        a = mult(a , a);
        b >>= 1;
    }
    return res;
}
int pascal[N][N];
int fact[N];
int ifact[N];
void pre(){
    memset(pascal , 0 , sizeof(pascal));
    for(int i = 0 ; i < N ; ++i){
        pascal[i][0] = 1;
        for(int j = 1 ; j <= i ; ++j){
            pascal[i][j] = add(pascal[i - 1][j - 1] , pascal[i - 1][j]);
        }
    }
    fact[0] = 1;
    ifact[0] = 1;
    for(int i = 1 ; i < N ; ++i){
        fact[i] = mult(fact[i - 1] , i);
        ifact[i] = mult(ifact[i - 1] , power(i , mod - 2));
    }
}
int dp[2][N];
int put[N][N];
int main(){
    pre();
    cin >> n >> a >> b >> c >> d;
    memset(dp , 0 , sizeof(dp));
    dp[(b + 1) & 1][0] = 1;
    memset(put , 0 , sizeof(put));
    for(int sz = 1 ; sz <= b ; ++sz){
        put[sz][1] = 1;
        for(int i = 2 ; i <= d && sz * i <= n ; ++i){
            put[sz][i] = (1LL * pascal[sz * i][sz] * put[sz][i - 1]) % mod;
        }
        for(int i = 1 ; i <= d ; ++i){
            put[sz][i] = mult(put[sz][i] , ifact[i]);
        }
    }
    for(int sz = b ; sz >= a ; --sz){
        for(int people = 0 ; people <= n ; ++people){
            long long res = dp[!(sz & 1)][people];
            for(int i = c ; i <= d ; ++i){
                if(i * sz <= people){
                    res += (1LL * ((1LL * pascal[people][i * sz] * dp[!(sz & 1)][people - i * sz]) % mod) * put[sz][i]) % mod;
                }
                else{
                    break;
                }
            }
            dp[sz & 1][people] = res % mod;
        }
    }
    printf("%d\n" , dp[a & 1][n]);
}

Measured memory_bytes: 8192
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
using namespace std;
vector<int>c[4];
int h, w, n, p, x[2], y[2], z[17][17];
int main() {
	cin >> p;
	for (int g = 0; g < p; g++) {
		c[0].clear();
		c[1].clear();
		c[2].clear();
		c[3].clear();
		memset(z, 0, sizeof(z));
		cin >> w >> h;
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> x[0] >> y[0] >> x[1] >> y[1];
			sort(x, x + 2);
			sort(y, y + 2);
			c[0].push_back(x[0]);
			c[1].push_back(y[0]);
			c[2].push_back(x[1]);
			c[3].push_back(y[1]);
		}
		z[0][0] = 1;
		for (int i = 0; i <= w; i++) {
			for (int j = 0; j <= h; j++) {
				for (int k = 0; k < n; k++) {
					if (i == c[0][k] && j == c[1][k] && i + 1 == c[2][k] && j == c[3][k]) {
						goto E;
					}
				}
				z[i + 1][j] += z[i][j];
			E:;
				for (int k = 0; k < n; k++) {
					if (i == c[0][k] && j == c[1][k] && i == c[2][k] && j + 1 == c[3][k]) {
						goto F;
					}
				}	z[i][j + 1] += z[i][j];
			F:;
			}
		}
		if (z[w][h] == 0) { cout << "Miserable Hokusai!" << endl; }
		else { cout << z[w][h] << endl; }
	}
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#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--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int main() {
    int x,y;
    cin>>x>>y;
    vector<int> vec(300);
    vec[1]=300000;
    vec[2]=200000;
    vec[3]=100000;
    int ans=0;
    if(x==1&&y==1) ans+=400000;
    cout<<ans+vec[x]+vec[y]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
int n;
ll m, a[N];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> m;
 	for(int i=1; i<=n; i++) cin >> a[i];
 	auto lcm = [](int x, int y)
 	{
 		return 1ll*x / __gcd(x, y) * y;
 	};
 	ll x = 0, y = 0, l = 1;
 	for(int i=1; i<=n; i++) 
 	{
	 	l = lcm(l, a[i]);
	 	if(l>2*m) return cout << 0 << '\n', 0;
	}
 	x = l/2;
 	y = l;
	for(int i=1; i<=n; i++)
	{
		if((l/a[i])&1) continue;
		return cout << 0 << '\n', 0;
	}
 	//debug(x); debug(y);
 	ll ans = 0;
 	if(x<=m)
 	{
 		ans++;
 		m -= x;
 		ans += m / y;
 	}
 	cout << ans;
	return 0;
}


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

namespace abc123
{
    class B
    {
        static void Main(string[] args)
        {
            int N = Input.Int();
            int[] V = Input.IntArray();
            int[] C = Input.IntArray();


            int X = 0;
            int Y = 0;
            for (int i = 0; i < N; i++)
            {
                if (C[i] < V[i])
                {
                    X += V[i];
                    Y += C[i];
                }
            }
            Console.WriteLine(X - Y);

        }

        internal static class Input
        {
            public static int Int() => int.Parse(Console.ReadLine());

            public static string Str() => Console.ReadLine();

            public static int[] IntArray() => Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        }
    }

    

}


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

int H,W,h,w,a[505][505];

void work()
{
	scanf("%d %d %d %d",&H,&W,&h,&w);
	if (H%h)
		{
			int x=H/h+1,y=-x*(h-1)-1;
			for (int i=1; i<=H; i++)
				for (int j=1; j<=W; j++)
					a[i][j]+=(i%h?x:y);
		}
	if (W%w)
		{
			int x=W/w+1,y=-x*(w-1)-1;
			for (int i=1; i<=H; i++)
				for (int j=1; j<=W; j++)
					a[i][j]+=(j%w?x:y);
		}
	if (!a[1][1])  puts("No"),exit(0);
	puts("Yes");
	for (int i=1; i<=H; i++,puts(""))
		for (int j=1; j<=W; j++)
			printf("%d ",a[i][j]);
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 2304
program main
implicit none
integer :: i, j, k
character :: s*1, t*5

read(*,*) s
t = 'aeiou'
do i = 1, 5
   if( s==t(i:i) ) then
      write(*,*) 'vowel'
      stop
   end if
end do
write(*,*) 'consonant'




end program main


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
using matrix = vector<vector<uint>>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acos(-1);

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

    int S, W;
    cin >> S >> W;
    cout << (S <= W ? "unsafe" : "safe") << endl;
    return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);
const ll MOD = (ll)(1e9 + 7);

int n;
int a[MAX_N];

int duplicate;
int duplicate_ind_fst;
int duplicate_ind_snd;

/////////////////////////////////////////////////////////////
class CombinationModulo {
 public:
  static const ll MOD = (ll)(1e9 + 7);

  vector<ll> fact;
  vector<ll> inv;
  vector<ll> fact_inv;

  CombinationModulo(int n) {
    this->fact = vector<ll>(n + 1, 0LL);
    this->inv = vector<ll>(n + 1, 0LL);
    this->fact_inv = vector<ll>(n + 1, 0LL);
    init(n);
  }

  void init(int n) {
    inv[1] = fact[0] = fact_inv[0] = 1LL;
    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;
    }
    for (int i = 1; i <= n; i++) {
      fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
  }

  ll comb(int n, int r) {
    if (r > n) return 0LL;
    return fact[n] * fact_inv[r] % MOD * fact_inv[n - r] % MOD;
  }
};
/////////////////////////////////////////////////////////////

int main(void) {
  // Here your code !
  scanf("%d", &n);

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

  set<int> visited;

  visited.insert(a[0]);

  for (int i = 1; i < n + 1; ++i) {
    if (visited.find(a[i]) != visited.end()) {
      duplicate = a[i];
      duplicate_ind_snd = i;
      break;
    }
    visited.insert(a[i]);
  }

  for (int i = 0; i < n + 1; ++i) {
    if (a[i] == duplicate) {
      duplicate_ind_fst = i;
      break;
    }
  }

  CombinationModulo comb_mod(n + 5);

  int available = (n + 1 - duplicate_ind_snd) + (duplicate_ind_fst + 1) - 1;

  for (int i = 1; i <= n + 1; ++i) {
    if (i == 1) {
      printf("%lld\n", n);
    }
    else {
      ll whole = comb_mod.comb(n + 1, i);

      if (i <= available) { // duplicate case
        ll minus = comb_mod.comb(available - 1, i - 1);

        whole -= minus;
        whole %= MOD;
        if (whole < 0) whole += MOD;
      }

      printf("%lld\n", whole);
    }
  }

  return 0;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
int n;
  cin >> n;
  ll a[n+5];
       for(int i=0;i<n;i++){
        cin >> a[i]; 
       }
  ll ans=0;
  		for(int i=0;i<n;i++)
          	for(int j=i+1;j<n;j++)
              	ans += a[i]*a[j];
  	cout<<ans;
       return 0;
}

Measured memory_bytes: 256
import sys

alp = "abcdefghijklmnopqrstuvwxyz"
D = {}
for i in range(26):
    D[alp[i]] = i 


N = int(input())

c = [{}]
num = [N]
dep = [0]

Slis = []
lon = 0


for loop in range(N):

    S = input()
    S += " "
    Slis.append(S)
    #Slen += len(S)

    nind = 0

    for i in S:

        if i not in c[nind]:
            lon += 1
            if len(c[nind]) == 1:
                lon -= 1
            c[nind][i] = len(c)
            c.append({})
            num.append(0)
            dep.append(dep[nind]+1)


        nind = c[nind][i]
        num[nind] += 1

Q = int(input())
#print (lon)

if lon < 70000:

    always = [0] * N
    table = []

    #print (c)
    #print (num)

    #table構築
    for loop in range(N):

        nt = [[0] * 26 for i in range(26)]
        nind = 0

        for i in Slis[loop]:

            if i == " ":
                continue

            #print ("now char",i)

            for j in c[nind]:
                #print ("nowj",j)
                if j == " ":
                    always[loop] += 1
                    #print ("always pl+1")
                elif j != i:
                    #print ("if",i,">",j,"plus:",num[c[nind][j]])
                    nt[D[i]][D[j]] += num[c[nind][j]]

            nind = c[nind][i]

        table.append(nt)

    #print (always)
    #print (table[0])

    #Q = int(input())

    for loop in range(Q):

        k,p = input().split()
        k = int(k)
        k-=1
    
        ans = always[k] + 1

        for i in range(26):
            for j in range(i):

                ind1 = D[p[i]]
                ind2 = D[p[j]]

                ans += table[k][ind1][ind2]

        print (ans)

    sys.exit()




#print (c)
#print (num)


lpc = 0

for loop in range(Q):

    k,p = input().split()
    k = int(k)

    p = " " + p
    nind = 0
    ans = 0

    ncr = 0

    while ncr < len(Slis[k-1]):

        i = Slis[k-1][ncr]

        for j in p:
            if j == i:
                break
            
            elif j in c[nind]:
                ans += num[c[nind][j]]

        while len( c[c[nind][i]] ) == 1:
            for x in c[c[nind][i]]:
                c[nind][i] = c[c[nind][i]][x]
            
        nind = c[nind][i]
        ncr = dep[nind]

    print (ans+1)



Measured memory_bytes: 379008
s = input()

x = 0
l = [0] * len(s)
for i in range(len(s)):
    if s[i] == "<":
        x += 1
        l[i] = x
    else:
        x = 0

x = 0
r = [0] * len(s)
for i in range(len(s))[::-1]:
    if s[i] == ">":
        x += 1
        r[i] = x
    else:
        x = 0

ans = l[-1] + r[0]
for i in range(len(s)-1):
    ans += max(l[i], r[i+1])
    
print(ans)

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

using namespace std;

int main()
{
    int N,D;
    cin>>N>>D;
    vector<vector<int>>v(N);
    for(int i=0;i<N;i++){
        for(int j=0;j<D;j++){
            int x;
            cin>>x;
            v[i].push_back(x);
        }
    }
    int k=0,cnt=0;
     for(int i=0;i<N-1;i++){
         for(int s=i+1;s<N;s++){
             k=0;
        for(int j=0;j<D;j++){
             k+=(pow((v[i][j]-v[s][j]),2));
        } 
        //cout<<k<<endl;
       long double p=sqrt(k);
        //cout<<p<<" "<<ceil(p)<<endl;
        if(p==floor(p))
            cnt++;
         }
        
     }
    cout<<cnt<<endl; 
   
        
    
}

Measured memory_bytes: 256
let split str delim =
  let open String in
  let rec doit s acc =
    match
      try Some (rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = sub s 0 i in
        doit s1 (sub s (i + 1) (length s - length s1 - 1) :: acc)
  in doit str []

let () =
  match List.map int_of_string (split (read_line ()) ' ') with
  | [n; k] -> begin
      let a = Array.init n (fun _ -> read_int ()) in
      let rec check p =
        let rec doit i j s =
          if i = n then n
          else if j >= k then i
          else
            let x = s + a.(i) in
            if x > p then doit i (j + 1) 0
            else doit (i + 1) j x
        in doit 0 0 0
      and bin_search l r =
        if r < l then l
        else
          let m = (l + r) / 2 in
          if check m >= n then bin_search l (m - 1)
          else bin_search (m + 1) r
      in Printf.printf "%d\n" (bin_search 0 (100000 * 10000))
    end
  | _ -> exit 1

Measured memory_bytes: 5256
using System;

namespace CS
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            if(s == "ABC")
            {
                Console.WriteLine("ARC");
            }
            else if(s == "ARC")
            {
                Console.WriteLine("ABC");
            }
        }
    }
}

Measured memory_bytes: 25784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i >= b; i--)
#define all(v) v.begin(), v.end()
#define mod 1000000007
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int gcd(int x, int y) {
    if (x < y) swap(x, y);
    while(y > 0) {
        int tmp = x % y;
        x = y;
        y = tmp;
    }
    return x;
}

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, 0, n) cin >> a[i];

    vector<int> left(n, 0), right(n + 1, 0);

    rep(i, 1, n) left[i] = gcd(left[i - 1], a[i - 1]);
    rrep(i, n - 2, 0) right[i] = gcd(right[i + 1], a[i + 1]);

    int ans = 0;
    rep(i, 0, n) ans = max(ans, gcd(left[i], right[i]));

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


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n, c, k;
  cin>>n>>c>>k;
  int t[n];
  REP(i, n)cin>>t[i];
  sort(t, t+n);

  int ans=0, await=0;
  REP(i, n){
    if(t[i]-t[await]>k){
      ++ans;
      await=i;
      continue;
    }
    if(i-await+1==c){
      ++ans;
      await=i+1;
    }
  }
  if(await!=n) ++ans;
  ECHO(ans);

  return 0;
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

double dp[3010][6020];

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

  int N;
  cin >> N;

  int offset = 3010;

  vector<double> p(N);

  rep(i, N) cin >> p[i];

  for(int i = 0; i < 3010; i++){
    for(int j = 0; j < 6020; j++){
      dp[i][j] = 0.0;
    }
  }

  dp[0][offset + 0] = 1.0;

  for(int i = 0; i < N; i++){
    for(int j = 1; j < 6015; j++){

      dp[i+1][j+1] += p[i] * dp[i][j];
      dp[i+1][j-1] += (1-p[i]) * dp[i][j];

    }
  }

  double ans = 0.0;

  for(int i = offset+1; i < 6015; i++){
    ans += dp[N][i];
  }

  cout << setprecision(20) << ans << endl;

  return 0;
}


Measured memory_bytes: 141952
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int maxn = 2e5+10;
long long n;
int main(){
    cin>>n;
    long long ans = (n/11)*2;
    //if(n% 11 == 0)   ans = anss;
    if(n%11 <= 6 && n%11!=0)   ans = ans+1;
    else if(n%11!=0)   ans = ans+2;
    cout << ans<<endl;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
tmp = h[0]
flg = True
for i in h:
    if tmp == i:
        pass
    elif tmp < i:
        tmp = i - 1
    else:
        flg = False
        break

if flg:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14224
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#include <cmath>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  vector<ll> dice(6);
  rep (i, 6) cin >> dice[i];
  string S;
  cin >> S;
  rep (i, S.size()) {
    if (S[i] == 'S') {
      ll tmp = dice[0];
      dice[0] = dice[4];
      dice[4] = dice[5];
      dice[5] = dice[1];
      dice[1] = tmp;
    }
    if (S[i] == 'N') {
      ll tmp = dice[0];
      dice[0] = dice[1];
      dice[1] = dice[5];
      dice[5] = dice[4];
      dice[4] = tmp;
    }
    if (S[i] == 'E') {
      ll tmp = dice[0];
      dice[0] = dice[3];
      dice[3] = dice[5];
      dice[5] = dice[2];
      dice[2] = tmp;
    }
    if (S[i] == 'W') {
      ll tmp = dice[0];
      dice[0] = dice[2];
      dice[2] = dice[5];
      dice[5] = dice[3];
      dice[3] = tmp;
    }
  }
  cout << dice[0] << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3220
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] costs = new int[n];
		int[] seconds = new int[n];
		int[] fulls = new int[n];
		for (int i = 0; i < n - 1; i++) {
		    costs[i] = sc.nextInt();
		    seconds[i] = sc.nextInt();
		    fulls[i] = sc.nextInt();
		}
		int[] times = new int[n];
		for (int i = 0; i < n - 1; i++) {
		    for (int j = 0; j <= i; j++) {
		        if (times[j] < seconds[i]) {
		            times[j] = seconds[i] + costs[i];
		        } else {
		            int d = (times[j] + fulls[i] - 1) / fulls[i];
		            times[j] = fulls[i] * d + costs[i];
		        }
		    }
		}
		
		
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
		    sb.append(times[i]).append("\n");
		}
     System.out.println(sb);
	}
}


Measured memory_bytes: 25512
#include <stdio.h>
#include <math.h>

int main(){
    int a, b;
    char op;
    
    while(1){
        scanf("%d %s %d", &a, &op, &b);
        if(a < 0 || a > 20000) break;
        if(b < 0 || b > 20000) break;
        
        switch(op){
          case '+':
            printf("%d\n", a + b);
            break;
            
          case '-':
            printf("%d\n", a - b);
            break;
            
          case '*':
            printf("%d\n", a * b);
            break;
            
          case '/':
            printf("%d\n", a / b);
            break;
            
          case '?':
            return 0;
        }
    }
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  int a[110];
  for( int i = 0; i < n; ++i ) cin >> a[i];

  sort(a, a + n, greater<int>());
  int Alice = 0;
  int Bob = 0;
  for( int i = 0; i < n; ++i ){
    if( i % 2 == 0 ) {
      Alice += a[i];
    }
    else Bob += a[i];
  }

  cout << Alice - Bob << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

#define int long long

const int INF = 1e18;

int n, m;
int a[5120];
int b[5120][201];

int ans = -1e18;

int g[5010][5010];

void Add(int i, int j, int val)
{
    if (i >= 0 && j >= 0) g[i][j] += val;
}

void Add(int x1, int x2, int y1, int y2, int val)
{
    Add(x1 - 1, y1 - 1, val);
    Add(x2, y1 - 1, -val);
    Add(x1 - 1, y2, -val);
    Add(x2, y2, val);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i + 1 < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> b[i][j];
        }
    }
    for (int j = 0; j < m; j++)
    {
        vector<int> L(n), R(n);
        vector<pair<int, int> > st = {{-1, INF}};
        for (int i = 0; i < n; i++)
        {
            while (b[i][j] > st.back().second)
            {
                st.pop_back();
            }
            L[i] = st.back().first;
            st.push_back({i, b[i][j]});
        }
        st = {{n, INF}};
        for (int i = n - 1; i >= 0; i--)
        {
            while (b[i][j] > st.back().second)
            {
                st.pop_back();
            }
            R[i] = st.back().first;
            st.push_back({i, b[i][j]});
        }
        for (int i = 0; i < n; i++)
        {
            Add(L[i] + 1, i, i, R[i] - 1, b[i][j]);
        }
    }
    for (int i = n - 1; i >= 0; i--)
    {
        for (int j = n - 1; j >= 0; j--)
        {
            g[i][j] = g[i][j] + g[i + 1][j] + g[i][j + 1] - g[i + 1][j + 1];
        }
    }
    for (int i = 0; i < n; i++)
    {
        int len = 0;
        for (int j = i; j < n; j++)
        {
            ans = max(ans, g[i][j] - len);
            len += a[j];
        }
    }
    cout << ans;
}


Measured memory_bytes: 204288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll A[100010];
    rep(i,0,N) cin >> A[i];
    ll val = 0;
    rep(i,0,N){
        if(i % 2 == 0){
            val += 2 * A[i];
        }else{
            val -= 2 * A[i];
        }
    }
    ll x = val / 2;
    ll tt = 0;
    vector<ll> ans;
    rep(i,0,N){
        if(i % 2 == 0){
            tt = A[i]*2 - tt;
            ans.push_back(tt-x);
        }else{
            tt = A[i]*2 - tt;
            ans.push_back(tt+x);
        }
    }
    cout << ans[N-1] << " ";
    rep(i,0,N-1){
        cout << ans[i] << " \n"[i == N-2];
    }



    
}

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

int main()
{
    int a,ct1=0,ct2=0;

    for(int i=0; i<3; i++)
    {
        scanf("%d",&a);
        if(a==5)
            ct1++;
        else if(a==7)
            ct2++;

    }
    if(ct1==2 && ct2==1)
        printf("YES\n");
    else
        printf("NO\n");

    return 0;
}


Measured memory_bytes: 256