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


int main(){
	string S;
	cin >> S;
	int N = S.size();
	ll ans =0;
	for (int i = 0;i < (1<<(N-1));i++){
		ll sm = 0;
		ll a = S[0] - '0';
		for (int j=0;j<N-1;j++){
			if (i & (1 << j)){
				sm += a;
				a = 0;
			}
			a = a * 10 + S[j+1] - '0';
		}
		sm += a;
		ans += sm;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define in(n) cin>>n>>
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
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;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    
     
    string s;
    
    cin >> s;
    
    if ((s[0]==s[1] && s[1]==s[2])||(s[1]==s[2] && s[2]==s[3])){
    
        cout << "Yes" << endl;
    
    }else{
        
        cout << "No" << endl;
        
    }
    
    /*78
    char x,y;
    
    cin >> x >> y;
    
    if((x-y)>0){
        
        cout << '>' << endl;
        
    }else if (x==y){
        
        cout << '=' << endl;
        
    }else{
        
        cout << '<' << endl;
        
    }
    */
    
    /*int s[3][2];
    
    rep(i,3){
        rep(j,3){
            
            cin >> s[i][j];
            
        }
    }
    
    if ((s[0][0]==s[2][1])&&(s[1][0]==s[1][1])&&(s[2][0]==s[0][1])){
    
    cout << "Yes" << endl;
    
    }else{
    
    cout << "No" << endl;
    
    }
    */
/////////////////////////////////////////////////////
return 0;}

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

int main(void)
{
    string x;
    cin>>x;
    string y=x;
    reverse(y.begin(),y.end());
    if(x==y)
    {
        cout <<"Yes"<<endl;
    }
    else
    {
        cout <<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ar array
#define pb push_back
#define forf(i,a,b) for(i = a; i< b; i++)
#define forb(i,a,b) for(i = b; i>=a; i--)
using namespace std;
const int mod = 1e9+7;
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int a,b;
	cin>>a>>b;
	int ans = 0;
	for(int i = a; i<=b; i++)
	{
		string s = to_string(i),g;
		g = s;
		reverse(g.begin(),g.end());
		if(g==s) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define int long long
signed  main(){
  double N,K,B;
  vector<int>a={0,1,3,1,2,1,2,1,1,2,1,2,1};
  str S1,S2,S3;
  cin>>N>>K;
  cout<<(a[N]==a[K]?"Yes":"No");
}


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

int main(){
    
    int a, b, counter;
	char postal[100];
	
	scanf("%d %d", &a, &b);
	scanf("%s", postal);
	
	for(int i = 0; i < a; i++){
		if(postal[i]>='0'&&postal[i]<='9'){
			counter++;
		}
	}
	for(int i = a + 1; i<a+b+1; i++){
		if(postal[i]>='0'&&postal[i]<='9'){
		counter++;
		}
	}
	if(postal[a]=='-'){
		counter++;
	}
	
	if(counter==a+b+1){
		printf("Yes");
	}else{
		printf("No");
	}
	}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#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 rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc092() {
	ll n;
	ll ans = 0;

	cin >> n;

	V a(n + 2);

	a[0] = 0;
	rep(i, n) {
		cin >> a[i + 1];
	}
	a[n + 1] = 0;

	V s(n + 2);
	s[0] = 0;
	rep(i, n + 1) {
		s[i + 1] = s[i] + abs(a[i + 1] - a[i]);
	}

	rep(i, n) {
		ans = s[n + 1] - abs(a[i + 1] - a[i]) - abs(a[i + 2] - a[i + 1]) + abs(a[i + 2] - a[i]);
		cout << ans << "\n";
	}
}

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

	solve_abc092();

	return 0;
}

Measured memory_bytes: 2816
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long ll;
const int maxn = 1e5+100;
int main()
{
    int x;
    cin >> x;
    if (x >= 400 && x < 600) cout << 8 << endl;
    else if (x < 800) cout << 7 << endl;
    else if (x < 1000) cout << 6 << endl;
    else if (x < 1200) cout << 5 << endl;
    else if (x < 1400) cout << 4 << endl;
    else if (x < 1600) cout << 3 << endl;
    else if (x < 1800) cout << 2 << endl;
    else if (x < 2000) cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

class Main{
	static Scanner s=new Scanner(System.in);
	static int gInt() {return Integer.parseInt(s.next());}
	static long gLong() {return Long.parseLong(s.next());}

	public static void main(String[]$){
		int a=gInt(),b=gInt();
		String regex="(\\d){"+a+"}-(\\d){"+b+"}";
		System.out.println(s.next().matches(regex)?"Yes":"No");
	}
}

Measured memory_bytes: 24020
/*
16D8103013E 銭　俊浩 Sen Shunkou
Aizu Online Judge 
コース「アルゴリズムとデータ構造入門」 
3_B: Queue
*/
#include <iostream>
#include <deque>
using namespace std;
int main()
{
    deque<int> que;
    int n,q,l;
    string a;
    int b;
    int tmp;
    cin>>n;

    for (int i = 0; i < n; i++)
    {
        cin>>a;
        if(a=="deleteFirst"){
            que.pop_front();
        }else if(a=="deleteLast"){
            que.pop_back();
        }else{
            cin>>b;
            if(a=="insert"){
                que.push_front(b);
            }
            if(a=="delete"){
                l=que.size();
                deque<int>::iterator ite = que.begin();
                for(ite;ite<que.end();ite++){
                    if(*ite==b){
                        que.erase(ite);
                        break;
                    }
                }
            }
        }
    }

    l=que.size();
    for(int i=0;i<l;i++){
        tmp=que.front();
        que.pop_front();
        if(i==l-1){
            cout<<tmp<<"\n";
        }else{
            cout<<tmp<<" ";
        }
    }
}


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

const ll MOD = 998244353;

ll modpow(ll x, ll n, ll m){
    ll res = 1, r = x;
    while(n){
        if(n % 2) res = res * r % m;
        r = r * r % m;
        n /= 2;
    }
    return res;
}

ll primroot(ll m, bool inv = false){
    if(!inv){
        if (m == 2) return 1;
        if (m == 167772161) return 3;
        if (m == 469762049) return 3;
        if (m == 754974721) return 11;
        if (m == 998244353) return 3;
    }
    else{
        if (m == 2) return 1;
        if (m == 167772161) return 55924054;
        if (m == 469762049) return 156587350;
        if (m == 754974721) return 617706590;
        if (m == 998244353) return 332748118;
    }
    return -1;
}

vector<ll> NTT(const vector<ll> &f, int n, const ll &m, bool inv){
    if(n == 1){
        return f;
    }
    ll z = modpow(primroot(m, inv), m / n, m);
    vector<ll> f0(n / 2), f1(n / 2);
    for(int i = 0; i < n / 2; i++){
        f0[i] = f[i * 2];
        f1[i] = f[i * 2 + 1];
    }
    vector<ll> Ff0 = NTT(f0, n / 2, m, inv), Ff1 = NTT(f1, n / 2, m, inv);
    vector<ll> Ff(n);
    ll zz = 1;
    for(int i = 0; i < n; i++){
        Ff[i] = (Ff0[i % (n / 2)] + zz * Ff1[i % (n / 2)]) % m;
        zz = zz * z % m;
    }
    return Ff;
}

vector<ll> Convolution(vector<ll> a, vector<ll> b, const ll m){
    int n = 1;
    while(n < (int)a.size() + (int)b.size() - 1) n <<= 1;
    a.resize(n);
    b.resize(n);
    vector<ll> Fa = NTT(a, n, m, false), Fb = NTT(b, n, m, false);
    vector<ll> Fc(n);
    for(int i = 0; i < n; i++) Fc[i] = Fa[i] * Fb[i] % m;
    vector<ll> c = NTT(Fc, n, m, true);
    for(int i = 0; i < n; i++) c[i] = c[i] * modpow(n, m - 2, m) % m;
    return c;
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<ll> a(n), b(m);
    for(int i = 0; i < n; i++) cin >> a[i];
    for(int i = 0; i < m; i++) cin >> b[i];
    vector<ll> c = Convolution(a, b, 998244353);
    for(int i = 0; i < n + m - 1; i++) cout << c[i] << " ";
    cout << endl;
}


Measured memory_bytes: 85180
#include<bits/stdc++.h>
using namespace std;
int h,t,q[205],sum;
long long s;
void solve(long long s){
	if (!s) return;
	if (s%2==0){
		solve(s-1);
		q[--h]=++sum;
	}
	else{
		solve(s/2);
		q[++t]=++sum;
	}
}
int main(){
	scanf("%lld",&s);
	h=50,t=49,sum=0;
	solve(s);
	printf("%d\n",sum*2);
	for (int i=h;i<=t;i++) printf("%d ",q[i]);
	for (int i=1;i<=sum;i++) printf("%d ",i);
}

Measured memory_bytes: 256
comm = {
        'N': ( 0, 1),
        'E': ( 1, 0),
        'W': (-1, 0),
        'S': ( 0,-1),
        }
while True:
    n = input()
    if n==0:
        break
    p = [[0]*21 for i in xrange(21)]
    for i in xrange(n):
        x, y = map(int, raw_input().split())
        p[y][x] = 1
    m = input()
    px, py = 10, 10
    count = 0
    for i in xrange(m):
        d, l = raw_input().split(); l = int(l);
        com = comm[d]
        while l>0:
            px += com[0]; py += com[1];
            if p[py][px]==1:
                p[py][px] = 0
                count += 1
            l -= 1
    print "Yes" if count==n else "No"

Measured memory_bytes: 4264
time=0
list1=[int(input()) for i in range(5)]
list2=[]
for i in range(5):
    tmp=0
    for j in range(5):
        if i==j or list1[j]%10==0:
            tmp+=list1[j]
        else:
            tmp+=(list1[j]-list1[j]%10+10)
    list2.append(tmp)
print(min(list2))

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#define N 2000

int A[N],n;

int solve(int i,int A[],int m,int B)
{
  int res;
  if(B==0) return 1;

  else if(m >= n) return 0;

  return (solve(n,A,m+1,B) || solve(n,A,m+1,B-A[m]));
}

int main()
{
  int i,j,m,B[200],sum;

  scanf("%d",&n);
  if(n > 20) exit(3);
  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&m);  
  for(j=0; j<m; j++){
    scanf("%d",&B[j]);    
  }

  for(i=0; i<m; i++){
    sum = solve(n,A,0,B[i]);
    if(sum == 1) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int x,n;cin>>x>>n;
    set<int> st;
    rep(i,n){
        int a;cin>>a;st.insert(a);
    }

    int res=INF,ans;
    for(int i=-1000;i<=1000;i++){
        if(st.count(i)) continue;
        if(chmin(res,abs(i-x))) ans=i;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define rep2(i,x,y) for (int i = x; i < (y); ++i)
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
//int INF = 100100101;
ll INF = 1000000000000000000;

int main()
{
  ios::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
  int n;
  cin >>n;
  vector<ll> in(n);
  boost::multiprecision::cpp_int ans = 1;
  rep(i,n){
    cin >> in[i];
  }
  bool exists = find(in.begin(), in.end(), 0) != in.end();
  if(exists) {
    cout << 0 << endl;
  }
  else{
    rep(i,n){
      ans *= in[i];
      if(ans > 1000000000000000000){
        cout << -1 << endl;
        break;
      }
    }
    if(ans <= 1000000000000000000) cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 4012
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();

		sc.close();

		int[] yaku = new int[15];
		int l = 1 ;

		for(int i = 100 ; i > 0 ; i--){
			if(A % i == 0 && B % i == 0){
				yaku[l] = i;
				l += 1;
			}
		}

		/*
		for(int j = 0 ; j < 15 ; j++){
			System.out.println(yaku[j]);
		}
*/
		System.out.println(yaku[K]);

	}

}

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

const int MAXK = 1e5 + 10;
const int MAXN = 1e3 + 10;

int A[MAXN],dp[MAXK],N,K;

int solve(int k){

	if(dp[k] != -1) return dp[k];

	if(k == 0) return dp[k] = 0;

	int ans = 0;
	for(int i = 1;i<=N;i++){
		if(A[i] > k) continue;
		if(solve(k - A[i]) == 0){
			ans = 1;
			break;
		}
	}

	return dp[k] = ans;

}

int main(){

	memset(dp,-1,sizeof(dp));
	cin >> N >> K;
	for(int i = 1;i<=N;i++){
		cin >> A[i];
	}

	if(solve(K)) printf("First\n");
	else printf("Second\n");

	return 0;

}

Measured memory_bytes: 7120
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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

            DateTime d = DateTime.Parse(str);

            DateTime dw = DateTime.Parse("2019/4/30");

            if (d <= dw)
            {
                Console.WriteLine("Heisei");
            }
            else
            {
                Console.WriteLine("TBD");
            }

        }
    }
}


Measured memory_bytes: 29124
#include<stdio.h>

int F[50];

int fibonacci(int n){
    if(n==0 || n==1) return F[n] =1;
    if(F[n] != -1) return F[n];
    return F[n] = fibonacci(n-2) + fibonacci(n-1);
}

int main(){
    int n,i;
    for(i=0; i<50; i++) F[i]=-1;

    scanf("%d",&n);
    printf("%d\n",fibonacci(n));

    return 0;
}



Measured memory_bytes: 2108
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	as := make([]int, n) // 食べた
	bs := make([]int, n) // 満足度
	cs := make([]int, n-1) // 追加

	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		as[i] = a - 1
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&bs[i])
	}
	for i := 0; i < n-1; i++ {
		fmt.Scan(&cs[i])
	}
	var sum int
	for i , a := range as {
		sum += bs[a]
		if i > 0 {
			if a - 1 == as[i-1] {
				sum += cs[a-1]
			}
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	REP(i,n){
		cin>>a[i];
		a[i]-=i;
	}
	sort(ALL(a));
	ll ans=LONG_MAX;
	if(n%2==0){
		ll sum=0;
		REP(i,n)sum+=abs(a[i]-a[n/2-1]);
		ans=min(ans,sum);
		sum=0;
		REP(i,n)sum+=abs(a[i]-a[n/2]);
		ans=min(ans,sum);
	}else {
		ans=0;
		REP(i,n)ans+=abs(a[i]-a[n/2]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

public class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        int[] cars = new int[10];
        int pos = -1;

        while( (line = br.readLine()) != null){
            int a = Integer.parseInt(line);
            if(a != 0){
                pos++;
                cars[pos] = a;
            }else{
                System.out.println(cars[pos]);
                cars[pos] = 0;
                pos--;
            }
        }

    }
}

Measured memory_bytes: 23972
#include <stdio.h>

int main(){
  int n;  scanf("%d", &n);
  int ans = 0, co = 1;
  for(int i=1; i<=n; i++){
    int t;  scanf("%d", &t);
    if(t == i){
      co++;
    }else{
      ans = ans + co/2;
      co = 1;
    }
  }
  ans = ans + co/2;
  printf("%d\n", ans);
  return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

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

using i64=int64_t;

void solve(){
    i64 N,T;
    cin >> N >> T;
    vector<i64> t(N);
    rep(i,0,N) cin >> t[i];
    i64 ans=t[N-1]+T;
    rep(i,0,N-1) if(t[i]+T<t[i+1]) ans-=t[i+1]-t[i]-T;
    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(){
    int m[5];
    int a[5];
	int total=0;
	int t=0;
	int last=0;
	int flag=0;
	
	for(int i=0;i<5;i++){
		m[i]=0;
	    scanf("%d",&m[i]);
	    a[i]=m[i]%10;
    }
    	for(int i=0;i<5;i++){
    	//printf("%d  , ",m[i]);
   	    //printf("%d¥n",a[i]);
    }

     
   	 for(int i=1;i<10;i++){
   	     for(int j=0;j<5;j++){
   	         if(flag==0 && i==a[j]){
   	             last=j;
   	             flag=1;
   	         }
   	     }
   	 }
   	

   //printf("%d¥n¥n",m[last]);

   for(int i=0; i<5; i++){
   if(i != last && a[i]!=0){
   	total += m[i]+(10-a[i]);
   	//printf("%d %d¥n",m[i],10-a[i]);
   	//printf("%d¥n¥n",total);
   }
   else if(a[i]==0){
    total += m[i];
    //printf("%d 0¥n",m[i]);
   	//printf("%d¥n¥n",total);
   }
   else{
   	total += m[i];
   }
   }
   
   printf("%d",total);
   
   return 0;
  }

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main()
{
    int i,left,tmp;
    int w[10];
    int first;
    while (scanf("%d", &left) != EOF) {
        memset(w,0,sizeof(w));
        for (i=9;i>=0;i--) {
            tmp = 1<<i;
            if (left>=tmp) {
                w[i]=1;
                left-=tmp;
            }
        }
        first = 1;
        for (i=0;i<10;i++) {
            if (w[i]) {
                if (first) printf("%d", 1<<i);
                else       printf(" %d",1<<i);
                first = 0;
            }
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 200005;

bool can(string& s,int x, int y){
  for(int i=x;i<y;i++){
    if(s[i]=='#'&&s[i+1]=='#')return false;
  }
  return true;
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
#endif
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  string s;
  cin>>s;
  a--,b--,c--,d--;
  if(can(s,a,c)==false || can(s,b,d)==false){
    cout<<"No"<<endl;
  } else {
    if(c<d)cout<<"Yes"<<endl;
    else {
      bool f = false;
      for(int i=b;i<=d;i++){
        if(s[i]!='#'&&s[i-1]!='#'&&s[i+1]!='#')f=true;
      }
      if(f)cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 640
//#pragma comment(linker, "/STACK:102400000,102400000") 
#pragma warning(disable:4996)
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x33ffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 2e6 + 10;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);
ll po(ll a, ll b) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }

ll n, lk, cnt;
ll val[maxn], res[maxn];

bool check()
{
	ll i, j, k;
	ll sum = 0;
	int num = 0;
	repp(i, 2, n)
	{
		ll t = val[i] + val[i - 1];
		if (t > sum)
		{
			sum = t;
			num = i - 1;
		}
	}
	cnt = 0;
	if (sum < lk)
	{
		return false;
	}
	else
	{
		for (i = 1; i < num; i++)
		{
			cnt++;
			res[cnt] = i;
		}
		for (i = n - 1; i > num; i--)
		{
			cnt++;
			res[cnt] = i;
		}
		cnt++;
		res[cnt] = num;
		return true;
	}
}

void solve()
{
	ll i, j, k;
	scanf("%lld%lld", &n, &lk);
	repp(i, 1, n)
	{
		scanf("%lld", &val[i]);
	}
	if (check())
	{
		puts("Possible");
		repp(i, 1, cnt)
		{
			printf("%d\n", res[i]);
		}
	}
	else
	{
		puts("Impossible");
	}
}


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


Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    VL A(N); REP(i,N) {
        cin >> A[i];
        A[i] *= 2;
    }

    LL ret = 0;

    REP(i,N){
        if(i%2 == 0){
            ret = A[i] - ret;
        }
        else{
            ret = A[i] - ret;
        }
        dump(ret)
    }
    //cout << ret / 2 << endl;
    VL ans(N);
    ans[0] = ret/2;
    FOR(i,1,N){
        ans[i] = A[i-1] - ans[i-1];
    }
    REP(i,N){
        cout << ans[i] << " ";
    }
    cout << endl;

}

Measured memory_bytes: 2944
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

sum = 0
for i in range(n):
    sum += b[i]
    if i != 0 and a[i-1] == a[i] - 1:
        sum += c[a[i - 1] - 1]

print(sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    ll n; cin >> n;
    string ans = "";
    ll n2 = n;

    ll d = 2;
    ll i = 0;
    while(n2 != 0) {
        if (n2 % d == 0) ans.push_back('0');
        else {
            ans.push_back('1');
            ll di = i % 2 ==  0 ? d/2 : -d/2;
            n2 -= di;
        }
        d *= 2;
        i++;
        //cerr << d << endl;
    }

    reverse(ALL(ans));
    if (ans.size() == 0) ans.push_back('0');

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class FXorSum3 {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      vector<ll> a(n);
      vector<int> b(60);
      rep(i, n) {
        cin >> a[i];
      }
      sort(all(a));
      rep(i, 60) {
        ll s = 1LL<<i;
        rep(j, n) {
          if (s&a[j]) {
            b[i]++;
          }
        }
      }

      ll ans = 0;
      set<int, greater<>> st;
      vector<bool> used(n);
      ll base = 0;
      rep(i, 60) {
        if (b[i]%2==1) {
          ans += (1LL<<i);
        } else if (b[i] > 0) {
          st.insert(i);
          base += (1LL<<i);
        }
      }

      rep(i, n) {
        a[i] &= base;
        if (a[i] == 0) used[i] = true;
      }

      vector<ll> vec2;
      for(auto e: st) {
        //debug(e);
        int k = -1;
        ll s = 1LL<<e;
        rep(i, n) {
          if (used[i]) continue;
          if (a[i]&s) {
            k = i;
            break;
          }
        }
        debug(k);
        if (k==-1) continue;
        vec2.push_back(a[k]);
        used[k] = true;
        rep(i, n) {
          if (used[i]) continue;
          if (a[i]&s) {
            a[i] ^= a[k];
          }
        }
      }

      ll ans2 = 0;
      for(auto e: vec2) {
        debug(e);
        chmax(ans2, ans2^e);
      }
      cout << ans + ans2*2 << endl;
    }
};

signed main() {
  FXorSum3 solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 1024
import sys

# ## COMBINATION (MOD) ## #
MOD = 10**9 + 7  # , N = 2*10**5 で 0.3s
N_MAX = 5 * 10**5  # 問題サイズに合わせて変えておく

fac = [1, 1]  # 元テーブル
facinv = [1, 1]  # 逆元テーブル
inv = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N_MAX + 1):
    fac.append((fac[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    facinv.append((facinv[-1] * inv[-1]) % MOD)


def cmb(n, r):
    if (r < 0 or r > n):
        return 0
    # r = min(r, n-r)
    return fac[n] * facinv[r] * facinv[n - r] % MOD


def prm(n, r):
    if (r < 0 or r > n):
        return 0
    # r = min(r, n-r)
    return fac[n] * facinv[n - r] % MOD


def main():
    N, M = map(int, sys.stdin.readline().rstrip().split())

    all = prm(M, N) ** 2 % MOD

    dup = 0

    for i in range(1, N + 1):

        tmp = prm(M, i) * prm(M - i, N - i) ** 2 % MOD
        tmp *= cmb(N, i) * (-1) ** (i - 1)

        dup += tmp % MOD

    print((all - dup) % MOD)

main()


Measured memory_bytes: 68160
#include<stdio.h>
int main(void){
  int K,S;
  int x,y,z,count;
  scanf("%d %d",&K,&S);
  for(x=0;x<=K;x++){
    for(y=0;y<=K;y++){
      if(0<=(S-x-y)&&(S-x-y)<=K) count++;
    }   
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,r;
  cin>>a>>b;
  if(a==b)r=a+b;
  else if(a>b)r=a+a-1;
  else r=b+b-1;
  cout<<r;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <memory.h>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main() {
	char c;
	int d;
	map<string, int> abo;
	for (string s; cin >> d >> c >> s; ) abo[s]++;
	cout << abo["A"] << endl;
	cout << abo["B"] << endl;
	cout << abo["AB"] << endl;
	cout << abo["O"] << endl;
	
	return 0;
}

Measured memory_bytes: 0
# https://atcoder.jp/contests/abc129/tasks/abc129_e
MOD = (10**9) + 7
a = 1
b = 0
gets.chomp.bytes do |c|
  next b = (b * 3)%MOD if c == 48
  b = (a + b * 3)%MOD
  a = (a * 2)%MOD
end

puts (a+b)%MOD

Measured memory_bytes: 1916
x,y=map(int,input().split())
if x==1 and y==1:
    print(1000000)
elif x<=3 and y<=3:
    print((8-x-y)*100000)
elif x<=3:
    print((4-x)*100000)
elif y<=3:
    print((4-y)*100000)
else:print(0)  

Measured memory_bytes: 3060
#include <cmath>
#include <ios>
#include <iostream>

using namespace std;

int main(int argc, const char *argv[]) {
  int d, n;
  cin >> d >> n;

  if (n == 100) {
    n++;
  }

  cout << static_cast<int>(pow(100, d)) * n << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;

    ll ans = 0;
    vector<long long> A(a);
    rep(i, a){
        cin >> A[i];
    } 
    vector<long long> B(b);
    rep(i, b) cin >> B[i];
    vector<long long> C(c);
    rep(i, c) cin >> C[i];

    sort(all(A),greater<ll>());
    sort(all(B),greater<ll>());
    sort(all(C),greater<ll>());
    rep(i,x){
        ans += A[i];
    }
    rep(i,y){
        ans += B[i];
    }

    
    ll red = x-1;
    ll green = y-1;

    
    string s = "";
    rep(i, c){
        if(red == -1 && green == -1){
            continue;
        }else if(red == -1){
            s = "green";
        }else if(green == -1){
            s = "red";
        }else if(A[red] > B[green]){
            s = "green";
        }else{
            s = "red";
        }


        if(s == "red"){
            if(C[i] > A[red]){
                ans -= A[red];
                ans += C[i];
                red--;
            }   
        }else{
            if(C[i] > B[green]){
                ans -= B[green];
                ans += C[i];
                green--;
            }    
        }
    }
    


    cout << ans << endl;
    
}

Measured memory_bytes: 2560
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var pri = PrimeList(55555);
            var ans = pri.Where(i => i % 5 == 1).Take(n).ToArray();
            Console.WriteLine(string.Join(" ", ans));
        }

        public static List<int> PrimeList(int p)
        {
            var pri = new List<int>();
            pri.Add(2);

            for(var i = 3; i <= p; i += 2)
            {
                var prime = true;
                
                for(var j = 3; j <= Math.Sqrt(i); j += 2)
                {
                    if (i % j == 0)
                    {
                        prime = false;
                        break;
                    }
                }
                if (prime) pri.Add(i);
            }

            return pri;
        }
    }
}

Measured memory_bytes: 13448
#include <iostream>

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

    std::string ans = "No";
    if(a < b){
        if(a < c && c < b){
            ans = "Yes";
        }
    }else{
        if(b < c && c < a){
            ans = "Yes";
        }
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 888
{-# LANGUAGE
    BangPatterns, MultiWayIf, TupleSections, TypeApplications #-}
{-# OPTIONS_GHC -O2 #-}


import Control.Arrow
import Control.Concurrent
import Control.Monad
import qualified Data.ByteString.Builder as B
import qualified Data.ByteString.Char8 as C
import Data.Complex
import Data.Char
import Data.Function
import Data.Function.HT
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS
import Data.List
import Data.Monoid
import Data.Ord
import qualified Data.Sequence as Sq
import Data.Vector.Algorithms.Search
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import Debug.Trace
import System.IO


------------------
-- #   Read   # --
------------------

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine



main :: IO ()
main = do
    [l,r,d] <- r'
    print $ length $ filter ((==0).(`rem`d)) [l..r]



Measured memory_bytes: 3732
card = []

for i in range(int(input())):
  s,num = input().split()
  num = int(num)
  if s == "S":card.append(num)
  elif s == 'H':card.append(13 + num)
  elif s == 'C':card.append(26 + num)
  elif s == 'D':card.append(39 + num)

for i in range(1,53):
  if i not in card:
    print((1<=i<=13)*'S ',end='')
    print((14<=i<=26)*'H ',end='')
    print((27<=i<=39)*'C ',end='')
    print((40<=i<=52)*'D ',end='')
    print((i-1)%13+1)


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int a, b, c;
    cin >> a >> b >> c;
    string ans = "No";
    if (a + b == c || a + c == b || b + c == a) ans = "Yes";
    cout << ans << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}


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

template
<
    typename TYPE,
    std::size_t SIZE
>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a,i,n) for(ll (i) = a ; (i) < (n) ; ++(i))
#define REP(i,n) REPS(0,i,n)

const int INF = 100001;

int m;

int main()
{
    cin >> m;
    int ans = 24;
    cout << ans+24-m << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reprv(i, n) for (int i = n - 1; i >= 0; i--)
#define ll long long
using namespace std;

const int LEFT = -1;
const int RIGHT = 1;

struct m {
    int dir;
    int landing_point;
    int cnt;
};

int main() {

    string s;
    cin >> s;

    m mass[s.size() + 1] ;

    rep(i, s.size()) {
        mass[i].dir = (s[i] == 'L') ? LEFT : RIGHT;
        mass[i].cnt = 0;
    }

    // 10^100回やるので普通の計算は厳しそう.
    // 最終的に、LRと境目のところに人に集まるようになるはず.
    // R  R  L  L  L  L  R  L  R  R  L  L
    //                <- -> <- ->       <-
    //             <-             -> <-
    // ->       <-
    //    -> <-
    // 1  2  3  4  5  6
    //    13 24 5  6
    //    24 135 6
    //   136 245
    //
    // RL からの距離が0... N回目はL R、N+1回目はR L
    //               1... N回目はR L、N+1回目はL R
    //               2... N回目はL R、N+1回目はR L
    //               3... N回目はR L、N+1回目はL R

    int tmpl = 0;
    int tmpr = 0;
    int orikaesi_l = -1;
    int orikaesi_r = -1;
    int last = RIGHT;
    mass[s.size()].dir = RIGHT;

    rep(i, s.size() + 1) {
        if (mass[i].dir == RIGHT && last == RIGHT) {
            tmpl++;
        }else if (mass[i].dir == LEFT && last == RIGHT) {
            orikaesi_l = i - 1;
            orikaesi_r = i;
            tmpr++;
        }else if (mass[i].dir == LEFT && last == LEFT) {
            tmpr++;
        }else if (mass[i].dir == RIGHT && last == LEFT) {
            mass[orikaesi_l].cnt = tmpl / 2 + tmpr / 2 + tmpl % 2;
            mass[orikaesi_r].cnt = tmpl / 2 + tmpr / 2 + tmpr % 2;

            tmpl = 0;
            tmpr = 0;
            tmpl++;
        }
    last = mass[i].dir;
    }

    rep(i, s.size()) {
        cout << mass[i].cnt << " ";
    }
    cout << endl;

    return 0;
}


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

int main() {
  long N;
  cin >> N;
  long sum = 0;
  for (int i = 1; i < N+1; i++){
    sum += i*(1 + N/i)*(N/i)/2;
  }
  cout << sum << endl;
}


Measured memory_bytes: 3596
def solve():
    N, T, S = map(int, input().split())
    a = [tuple(map(int, input().split())) for _ in [0]*N]
    dp = [float("-inf")]*(T+1)
    dp[0] = 0

    for fun, mise_time in a:
        for prev_time, to_fun in zip(range(T-mise_time, -1, -1), dp[::-1]):
            new_time = prev_time + mise_time
            new_fun = fun + dp[prev_time]
            if prev_time < S < new_time:
                new_time = S + mise_time
                if new_time > T:
                    continue
                to_fun = dp[new_time]
            if new_fun > to_fun:
                dp[new_time] = new_fun

    print(max(dp))


if __name__ == "__main__":
    solve()

Measured memory_bytes: 8424
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdlib>
#define NMAX 100
#define WMAX 100
#define HMAX 100
using namespace std;
int dp[WMAX][HMAX] = {};
int W,H,N;
void paint(int x,int y,int a){
	if(a == 1){
		for (int i = 0; i < x; ++i)
		{
			for (int j = 0; j < H; ++j)
			{
				dp[i][j] = 1;
			}
		}
	}else if(a == 2){
		for (int i = W-1; i >= x; --i)
		{
			for (int j = 0; j < H; ++j)
			{
				dp[i][j] = 1;
			}
		}
	}else if(a == 3){
		for (int i = 0; i < W; ++i)
		{
			for (int j = 0; j <= y; ++j)
			{
				dp[i][j] = 1;
			}
		}
	}else{
		for (int i = 0; i < W; ++i)
		{
			for (int j = H-1; j > y; --j)
			{
				dp[i][j] = 1;
			}
		}
	}
}
int main(){
	int x[NMAX],y[NMAX],a[NMAX],sum = 0;
	cin >> W >> H >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> x[i] >> y[i] >> a[i];
		paint(x[i],y[i]-1,a[i]);
	}
	for (int i = 0; i < W; ++i)
	{
		for (int j = 0; j < H; ++j)
		{
			// cout << dp[i][j];
			if(dp[i][j] == 0){
				sum++;
			}
		}
		// cout << "\n";
	}
	// for (int i = 0; i < H; ++i)
	// {
	// 	for (int j = 0; j < W; ++j)
	// 	{
	// 		cout << dp[j][i];
	// 	}
	// 	cout << "\n";
	// }
	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	int k;
	while(cin>>k){
		if(k&1){
			cout<<(k/2)*((k+1)/2)<<endl;
		}
		else{
			cout<<(k/2)*(k/2)<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
/* Tuan Kkura */
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define base 31
#define MOD 1e9+7
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORs(i, a, b) for(int i = a; i >= b; i--)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define __FOR(i, a, b, k) for(int i = a; i <= b; i+= k)
#define __REP(i, a, b, k) for(int i = a; i < b; i+= k)
#define pb push_back
#define _io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

typedef pair <int, int> ii;
typedef vector <ii> vii;
#define fi first
#define se second
#define mp make_pair
#define PROB "text"
#define MAXN 200005

int main()
{
    _io
    int n, k; cin >> n >> k;
    int res = 0;
    FOR(i, 1, n)
    {
        int x; cin >> x;
        if(x >= k)  res++;
    }
    cout << res;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s,ss;
	int sum=0,i,ta,len,a[100],b[100],j,sa=0,sb=0,n,x,k=0,m,a1,a2,a3,a4,max=0;
	cin>>n;
	cin>>s;
	for(i=0;i<=s.length()-1;i++){
		if(s[i]=='I')sum++;
		if(s[i]=='D')sum--;
		if(max<sum)max=sum;
	}
	cout<<max;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll h,w;
    cin >> h >> w;
    vector<vector<char>>mp(h,vector<char>(w));
    for(ll i=0;i<h;i++){
        for(ll j=0;j<w;j++) cin >> mp[i][j];
    }
    vector<ll>tate,yoko;
    for(ll i=0;i<h;i++){
        bool ok=true;
        for(ll j=0;j<w;j++){
            if(mp[i][j]=='#') ok=false;
        }
        if(ok){
            yoko.push_back(i);
        }
    }
    for(ll i=0;i<w;i++){
        bool ok=true;
        for(ll j=0;j<h;j++){
            if(mp[j][i]=='#') ok=false;
        }
        if(ok) tate.push_back(i);
    }
    for(ll i=0;i<h;i++){
        bool ok1=false;
        for(ll k=0;k<yoko.size();k++){
            if(i==yoko[k]) ok1=true;
        }
        if(ok1) continue;
        for(ll j=0;j<w;j++){
            bool ok=false;
            for(ll k=0;k<tate.size();k++){
                if(j==tate[k]) ok=true;
            }
            if(ok) continue;
            cout << mp[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 3604
#include<stdio.h>
int main()
{
    char op;
    int a, b, f;
    f = 0;
    while(1){
        scanf("%d %c %d", &a, &op, &b);
        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;
            default:
                return 0;
        }
    }
}


Measured memory_bytes: 2060
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin >> n;
  int ary[n];
  for(int i = 0; i < n; i++) cin >> ary[i];
  int sum = 0;
  for(int i = 0; i < n - 1; i++){
    for(int j = i + 1; j < n; j++) sum += ary[i] * ary[j];
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define MOD 1000000007
#define all(c) c.begin(), c.end()
#define rep(i, s, e) for (auto i = s; i < e; i++)
#define peek(c)      \
	for (auto i : c) \
		cout << i << ' ';

void solve()
{
	ll n;
	cin >> n;
	vector<ll> v(n);
	ll sum = 0, tsum = 0;
	rep(i, 0, n)
	{
		cin >> v[i];
		sum += v[i];
	}
	ll d = INT_MAX;
	for (ll i = n - 1; i > 0; i--)
	{
		tsum += v[i];
		sum -= v[i];
		d = min(d, abs(sum - tsum));
	}
	cout << d;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	cerr << "\n\n~" << 500 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

int dp[41][401][401];

int main(int argc, char const *argv[]) {
    int n, Ma, Mb;
    cin >> n >> Ma >> Mb;
    vector<int> a(n+1);
    vector<int> b(n+1);
    vector<int> c(n+1);
    REP(i,n) cin >> a[i] >> b[i] >> c[i];
    REP(i,41) REP(j,401) REP(k,401) dp[i][j][k] = INF;
    int ans = INF;
    dp[0][0][0] = 0;
    REP(i,n) REP(j,401) REP(k,401) {
        dp[i+1][j][k] = dp[i][j][k];
        if(a[i] > j || b[i] > k) continue;
        dp[i+1][j][k] = min(dp[i][j-a[i]][k-b[i]]+c[i], dp[i][j][k]);
    }
    for(int j = 1; j < 401; ++j) for(int k = 1; k < 401; ++k) if(j*Mb == k*Ma) ans = min(ans, dp[n][j][k]);
    /*for(int i = 0; i < 5; ++i) {
        cout << "i = " << i << "\n" << std::endl;
        for(int j = 0; j < 5; ++j) {
            cout << "j = " << j << " | ";
            for(int k = 0; k < 5; ++k) {
                cout << dp[i][j][k] << "\t";
            }
            cout << "" << std::endl;
        }
        cout << "" << std::endl;
    }*/
    if (ans == INF) cout << -1 << std::endl;
    else cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 25984