akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
void quicksort(int ,int );
int n,W[1000];
int main(void){
  int i,cost1,cost2,total_cost=0,now,S,min,x=10000,rate;//S is sum
  int Copy[1000],Element[10001],Bool[1000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&W[i]);
    Copy[i]=W[i];
    Bool[i]=0;
    if(x>W[i])x=W[i];
  }

  quicksort(0,n-1);
  //calculate cost
  i=0;
  while(i<n){
    Element[W[i]]=i;
    i++;
  }
  
  i=0;
  while(i<n){
    if(Bool[i]==0){
      now=i;
      S=0;
      min=10000;
      rate=0;
      while(1){
        Bool[now]=1;
        rate++;
        if(min>Copy[now])
          min=Copy[now];
        S+=Copy[now];
        now=Element[Copy[now]];
        if(Bool[now]==1)break;
      }
      cost1=S+(rate-2)*min;
      cost2=S+min+(rate+1)*x;
      if(cost1<cost2)
        total_cost+=cost1;
      else total_cost+=cost2;
    }
    i++;
  }
  //finish calculate cost

  printf("%d\n",total_cost);
  return 0;
}
//quicksort include partition
void quicksort(int head,int last){
  int element;
  if(last-head>0){
    element=partition(head,last);
    quicksort(head,element-1);
    quicksort(element+1,last);
  }
}
int partition(int head,int last){
  int i,temp,last_number;
  last_number=W[last];
  for(i=head;i<last;i++){
    if(W[i]<=last_number){
      temp=W[head];
      W[head++]=W[i];
      W[i]=temp;
    }
  }
  temp=W[head];
  W[head]=W[last];
  W[last]=temp;
  return head;
}


Measured memory_bytes: 2108
'''
Created on Mar 11, 2013

@author: wukc
'''
import sys
import itertools


for l in sys.stdin:
    n=int(l)
    cnt=0
    for x,y,z in itertools.product(range(10),repeat=3):
        if n-(x+y+z) in range(10): cnt+=1
    print cnt

Measured memory_bytes: 4360
N=int(input())
arr=list(map(int,input().split()))
min_,max_=min(arr),max(arr)
ans=None

if max_-min_ > 1:
    ans=False
elif max_-min_ == 1:
    """
    A=max_
    y=len([a for a in arr if a==max_])
    x=N-y
    nc=A-x
    ans=(A-x)>0 and y >=2*(A-x)
    """
    
    y=len([a for a in arr if a==max_])
    x=N-y
    nc=max_-x
    ans=nc>0 and y>=2*nc

else:
    ans=N>=2*min_ or min_+1==N

print("Yes" if ans else "No")


Measured memory_bytes: 56004
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>

using namespace std;

int main() {
	int h[10];
	for (int i = 0; i < 10; i++)cin >> h[i];

	sort(h, h + 10);
	reverse(h, h + 10);
	cout << h[0] << endl << h[1] << endl << h[2] << endl;
}


Measured memory_bytes: 3092
#include<iostream>
using namespace std;
int main() {
	long long int N;
	long long int A[199999];
	long long int B[200000] = {};
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		cin >> A[i];
		B[A[i] - 1]++;
	}
	for (int j = 0; j < N; j++) {
		cout << B[j] << endl;
	}
	return 0;
}

Measured memory_bytes: 6760
#include <stdio.h>
#include <algorithm>
using namespace std;
int n, r[500]; long double x[501];
int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d", &r[i]);
    for(int i = 0; i < n; i++) {
        x[i] = r[i];
        for(int j = 0; j < i; j++) {
            long double dist = sqrtl((r[j] + r[i]) * (r[j] + r[i]) - (r[j] - r[i]) * (r[j] - r[i]));
            x[i] = max(x[i], x[j] + dist);
        }
    }
    long double ret = 0.0;
    for(int i = 0; i < n; i++) {
        ret = max(ret, x[i] + r[i]);
    }
    printf("%.9Lf\n", ret);
    return 0;
}

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

int main(){
    ll n; cin >> n;
    map<string,ll> m;
    //mapとは、連想配列を扱うためのライブラリの一つのこと。
    //map<キー型, 値型> 変数名;
    
    for(ll i=0;i<n;i++){
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        m[s]++;
    }
     
    ll ans=0;
    for(auto p:m){
        ll x=p.second;
        ans+=x*(x-1)/2;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
n = gets.chomp.to_i

s = 1
d = 2
w = 1
fld = false
while s < 10**5 do
    if s == n then
        flg = true
        break
    end
    s += d
    d += 1
    w += 1
end

if flg then
    puts("Yes")
    h = w + 1
    a = Array.new(h).map{Array.new(w, 0)}

    # ななめ
    num = 1
    add = w
    for j in 0..(w - 1) do
        for i in [j, j+1] do
            a[i][j] = num
        end
        num += add
        add -= 1
    end

    #右上
    for i in 0..(h - 1) do
        for j in i+1..(w - 1) do
            a[i][j] = a[i][j - 1] + 1
        end
    end

    #左上
    for j in 0..(w - 1) do
        for i in (j+2)..(h - 1) do
            a[i][j] = a[i-1][j] + 1
        end
    end

    # 結果の出力
    puts(h)
    for i in 0..(h - 1) do
        print(w.to_s + " ")
        for j in 0..(w - 1) do
            print(a[i][j].to_s + " ")
        end
        print("\n")
    end

    if false then
    for i in 0..(h - 1) do
        for j in 0..(w - 1) do
         print(a[i][j].to_s + " ")
        end
         print("\n")
    end
    end
else
    puts("No")
end


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

#define ll long long

using namespace std;



int n;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    vector <int> v(n);
    for (int i=0; i<n; i++) cin>>v[i];
    int i=1,j=n-1,s1=v[0],s2=0;
    while (i!=j){
        if(s1>s2){
            s2+=v[j];
            j--;
        }
        else{
            s1+=v[i];
            i++;
        }
    }
    if(s1<s2) s1+=v[i];
    else s2+=v[i];
    cout<<abs(s2-s1);
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<tuple>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

const ll mod = 1e9+7;
const ll INF = ll(1e18)+1;
const ll MAXN = 1e6;

int main()
{
    vector<tuple<string,int,int>> rest;
    int n;
    cin>>n;
    string s;
    int p;
    rep(i,n)
    {
        cin>>s>>p;
        p=-p;
        rest.emplace_back(make_tuple(s,p,i+1));
    }
    sort(rest.begin(),rest.end());
    for(auto it:rest)
    {
        cout<<get<2>(it)<<endl;
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
int L[100001];
int R[100001];
//bool ok[100001];
bool not_prime[100001];
int count[100001];
bool is_prime(int n){
    if (not_prime[n]==true){
        return false;
    }
    if (n==2){
        return true;
    }
    if (n%2==0){
        return false;
    }
    int qrt=(int)sqrt(double(n));
    for (int i=3;i<=qrt;i+=2){
        if (n%i==0){
            return false;
        }
    }
    return true;
}/*
int ans(int a,int b){
    int cnt=0;
    int i;
    if (a%2==0){
        i=a+1;
    }
    else {
        i=a;
    }
    for (;i<=b;i+=2){
        if (ok[i]==true){
            cnt++;
        }
        else {
            if (not_prime[i]==false&&not_prime[(i+1)/2]==false){
                cnt++;
                ok[i]=true;
            }
        }
    }
    return cnt;
}*/
void set_prime(){
    count[3]=1;
    count[4]=1;
    not_prime[1]=true;
    for (int i=4;i<100001;i+=2){
        not_prime[i]=true;
    }
    for (int i=3;i<100001;i+=2){
        if (not_prime[i]==true){
            count[i+1]=count[i]=count[i-1];
            continue;
        }
        if (is_prime(i)==true){
            int j_end=100001/i;
            for (int j=3;j<=j_end;j+=2){
                not_prime[i*j]=true;
            }
            if (not_prime[(i+1)/2]==false){
                count[i+1]=count[i]=count[i-1]+1;
            }
            else {
                count[i+1]=count[i]=count[i-1];
            }
        }
    }
}
int main(){
    set_prime();
    int q;
    scanf("%d",&q);
    for (int i=1;i<=q;i++){
        scanf("%d%d",&L[i],&R[i]);
    }
    for (int i=1;i<=q;i++){
        int tmp=0;
        if (count[R[i]]==0&&count[L[i]]==0){
            tmp=0;
        }
        else if (count[L[i]]==0){
            tmp=count[R[i]];
        }
        else if (count[L[i]]==count[L[i]-1]){
            tmp=count[R[i]]-count[L[i]];
        }
        else {
            tmp=count[R[i]]-count[L[i]]+1;
        }
        printf("%d\n",tmp);
    }
    return 0;
}


Measured memory_bytes: 2424
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef pair<int,int> P;
const int INF = 1000000000;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
int main(){
    int H,W;cin >> H >> W;
    vector<vector<char> > grid(H,vector<char>(W));
    vector<vector<int> > dist(H,vector<int>(W,INF));
    int cnt = 0;
    rep(i,H){
        rep(j,W){
            cin >> grid[i][j];
            if(grid[i][j] == '.')cnt++;
        }
    }
    queue<P> que;
    que.push(make_pair(0,0));
    dist[0][0] = 0;

    while(!que.empty()){
        P p = que.front();
        que.pop();
        if(p.first == H-1 && p.second == W-1)break;
        rep(i,4){
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if(nx < 0 || ny < 0 || nx >= W || ny >= H)continue;
            if(dist[ny][nx] != INF || grid[ny][nx] != '.')continue;
            que.push(make_pair(ny,nx));
            dist[ny][nx] = dist[p.first][p.second]+1;
        }
    }
    if(dist[H-1][W-1] == INF)puts("-1");
    else{
        int ans = cnt - dist[H-1][W-1] - 1;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define END getchar();getchar();return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

signed main() {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if (e-a<=k){
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}

	END;
}

Measured memory_bytes: 256
from collections import Counter, defaultdict
from sys import getrecursionlimit,setrecursionlimit
setrecursionlimit(100*getrecursionlimit())
G = defaultdict(list)
C = Counter()
N = int(input())
ans = {}
o = []
for i in range(N-1):
    a, b = map(int, input().split())
    C[a] += 1
    C[b] += 1
    G[a].append(b)
    G[b].append(a)
    ans[(a, b)] = 0
    o.append((a,b))

a = C.most_common(1)[0][0]
b = C.most_common(1)[0][1]

visited = [False] * (N+1)
def dfs(v, p):
    visited[v] = True
    counter = 1
    for c in G[v]:
        if not visited[c]:
            if p != 0 and counter == ans[(v, p)]:
                counter += 1
            ans[(v, c)] = ans[(c, v)] = counter
            counter += 1
            dfs(c, v)

dfs(a, 0)

print(b)
for a,b in o:
    print(ans[(a,b)])


Measured memory_bytes: 90064
#include <cstdio>
#include <vector>
using namespace std;
 
int main() {
  int num_query; scanf("%d", &num_query);
  vector<int> nums;
   
  while (num_query--) {
    int command; scanf("%d", &command);
     
    switch (command) {
      case 0:
        int x; scanf("%d", &x);
        nums.push_back(x);
        break;
         
      case 1:
        int p; scanf("%d", &p);
        printf("%d\n", nums[p]);
        break;
      
      case 2:
        nums.pop_back();
        break;
    }
  }
}


Measured memory_bytes: 3428
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  ll N;
  cin>>N;
  vector<ll> A(N);
  bool C=true;
  rep(i,N)cin>>A.at(i);
  sort(A.begin(),A.end());
  if(N%2==0){
    rep(i,N){
      if(A.at(i)!=(i/2)*2+1)C=false;
    }
  }
  else{
    rep(i,N){
      if(A.at(i)!=((i+1)/2)*2)C=false;
    }
  }
  if(C)cout<<powerup(2,N/2,MOD)<<endl;
  else cout<<0<<endl;
}

Measured memory_bytes: 1024
n = int(input())
S = input()
 
ans = S.count('E')
 
w = 0
tmp_w = 0
e = ans
 
for s in S:
    if s == 'E':
        e -= 1
    else:
        tmp_w += 1
 
    ans = min(ans, w+e)
    w = tmp_w
 
print(ans)

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

int main()
{
	string s = "";
	cin >> s;
	for (int i = 'a'; i <= 'z'; i++)
	{
		if (find(s.begin(), s.end(), i) == s.end())
		{
			cout << (char)i << endl;
			return 0;
		}
	}
	cout << "None" << "\n";
	return 0;
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int num = 0;
    int ans = 0;
    for (char c : s) {
        if (c == 'I') num++;
        else num--;
        ans = max(ans, num);
    }
    cout << ans << endl;
}


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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {

    int n;
    cin >> n;

    int ans = 180 * (n - 2);
    printf("%d\n", ans);

}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rept(i,k,n) for(int i = (k); i < (int)(n); i++)


typedef long long ll;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    int k = 1;
    rep(i,n){
        if(k==a[i]){
            k++;
        }
    }
    if (k==1) cout<<-1<<endl;
    else cout<<n-(k-1)<<endl;
    return 0;
}

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

int main() {
 long long n,k;
    cin >> n >> k;
    
    vector<long long> a(n);
    rep(i,n) {
     cin >>a[i];
    }
    
    
    for(int i = 0; i<n-k;i++) {
        if(a.at(i) < a.at(k+i)) {
         cout << "Yes" << endl;
        } else {
        cout <<"No" << endl;
        }
     }
    
    
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
using namespace std;
int A [200010];
int main() {
	int n; cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> A[i];
		A[i] -= i + 1;
	}
	sort(A, A + n);
	int med = A[n / 2];
	long long ans = 0;
	for(int i = 0; i < n; i++) {
		ans += abs(A[i] - med);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
constexpr ll mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
typedef long long           ll;
#define REP(i, n)           for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)       for (ll i = m ; i < (ll)n ; ++i)
#define INF                 (ll)1e15
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	ll K, A, B;
	cin >> K >> A >> B;
	
	
	string ans = "NG";
	for (ll i = A; i <= B; i++) {
		if (i % K == 0) {
			ans = "OK";
			break;
		}
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3596
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	string S;
	scan(S);
	int flag=0;
	rep(i,S.size()-1){
		if(S[i]=='A'&&S[i+1]=='C') flag=1;
	}
	if(flag) prin("Yes");
	else prin("No");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int a[5],i,j;
  for(i=0;i<5;i++)
  {
    cin>>a[i];
    if(a[i]==0)
      j=i+1;
  }
  cout<<j<<endl;
  return 0;
}

Measured memory_bytes: 3588
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main(){
    string s;
    int q, count;
    bool rev;
    cin >> s >> q;
    
    for (int i=0; i<q; i++) {
      string query;
      cin >> query;
      
      if (query == "1") {
        rev = !rev;
        count++;
        continue;
      }
      
      int t;
      string ch;
      cin >> t >> ch;
      if (t == 1){
        if (rev)
          s.append(ch);
        else
          s.insert(0, ch);
      } else {
        if (rev)
          s.insert(0, ch);
        else
          s.append(ch);
      }
    }

    if (count%2 == 1){
      reverse(s.begin(), s.end());
      cout << s << endl;
    } else {
      cout << s << endl;
    }
    
    return 0;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int main() {
  ll N, K;
  cin >> N >> K;
  ll A, B;
  A = B = 0;
  ll X;
  rep(i, N) {
    cin >> X;
    if(X % 2 == 0) {
      A++;
    }
    else {
      B++;
    }
  }
  ll P = 1;
  rep(i, A) {
    P *= 2;
  }
  ll Q = 1;
  if(K == 0) {
    if(B == 0) {
      Q = 1;
    }
    else {
      rep(i, B - 1) {
        Q *= 2;
      }
    }
  }
  else {
    if(B == 0) {
      Q = 0;
    }
    else {
      rep(i, B - 1) {
        Q *= 2;
      }
    }
  }
  cout << P * Q << endl;
}

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

int main(){
    vector<string> S;
    int N,L;
    cin>>N>>L;
    for(int i=0;i<N;i++){
        string tmp;
        cin>>tmp;
        S.push_back(tmp);
    }
    sort(S.begin(),S.end());
    for(int i=0;i<N;i++) cout<<S[i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
 
typedef long long ll;
typedef long double ld;
 
#define REP(i,a,n) for(int (i)=(a); (i)<(int)(n); (i)++)
#define rep(i,n) REP(i,0,n)
#define vec vector 

int main(){
  int A, B, T;
  cin >> A >> B >> T;
  
  cout << (T/A)*B;
    
}

Measured memory_bytes: 256
//usr_name : paras.gautam243
//dated :

#include<iostream>
using namespace std;

int main(){
//#ifndef ONLINE_JUDGE
   //freopen("in.txt", "r", stdin);
   //freopen("out.txt", "w", stdout);
//#endif

ios::sync_with_stdio(0);
cin.tie(0);


//...
string s,str="";
cin>>s;

for(auto g:s)
{
	if(g=='0' or g=='1')
		str.push_back(g);
 
	else if (g=='B' or str.empty())
		str.pop_back();
}

cout<<str;


return 0;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const ll mod = 1000000007;
ll inv[10000100];
ll FactorialInv[10000100];
ll Factorial[10000100];
ll beki(ll a, ll b){
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}
void init_combination(){
    const int MAX = 10000002;
    Factorial[0] = 1;
    inv[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = beki(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
    for(int i = 1; i <= MAX; i++) {
        inv[i] = FactorialInv[i] * Factorial[i-1] % mod;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}

ll N, K;
ll A[200500];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    init_combination();
  cin >> N >> K;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A, A + N);
  ll ans = 0;
  for(int i = K - 1; i < N; i++) {
    ans += combination(i, K - 1) * A[i];
    ans %= mod;
  }
  for(int i = 0; i < N; i++) {
    if(N - 1 - i >= K - 1) ans -= combination(N - 1 - i, K - 1) * A[i];
    ans %= mod;
    ans += mod;
    ans %= mod;
  }
  cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}


signed main() {
    accell();
    int a, b, c;
    cin >> a >> b >> c;
    if (c >= a) {
        c -= a;
        a = 0;
    } else {
        a -= c;
        c = 0;
    }
    if (c >= b) {
        c -= b;
        b = 0;
    } else {
        b -= c;
    }
    cout << a << ' ' << b;
    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
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;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            char c = in.next().charAt(0);
            if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
                out.println("vowel");
            else
                out.println("consonant");
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isPrintableChar(int c) {
            return c >= 33 && c <= 126;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();

            int b = readByte();
            while (!isPrintableChar(b))
                b = readByte();

            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }

            return sb.toString();
        }

    }
}



Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
long long q,h,s,d,n;
void solve()
{
    long long ans=0;
    while(n)
    {
        if (n>=2)
        {
            ans+=n/2*min(min(8*q,4*h),min(2*s,d));
            n%=2;
        }
        else
        {
            ans+=min(4*q,min(2*h,s));
            n--;
        }
    }
    cout<<ans<<endl;
}
int main()
{
    while(cin>>q>>h>>s>>d>>n)
        solve();
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        s: chars,
    }
    let h = s[0].clone();
    let t = s[s.len() - 1].clone();
    println!("{}{}{}", h, s.len() - 2, t);
}

Measured memory_bytes: 4352
## Date.parse を使うとわかりやすい
require "date"  ## date.parse 等、外部ファイルを使う場合必須

s = gets.chomp#.split.map(&:to_i)

ans = Date.parse(s)

date = Date.parse("2019/04/30") # '2019/04/30'は文字列として認識

if ans <= date
  puts "Heisei"
else
  puts "TBD"
end

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

int main(){

  int R,G,B,n;
  int r,g,b;
  cin >> R >> G >> B >> n;
  int ct = 0;
  int N;
  r = n/R;
  g = n/G;
  b = n/B;
  for(int i=0;i<=r;i++){
    for(int j=0;j<=g;j++){
      N = n-(i*R)-(j*G);
        if(N%B==0&&N>=0){
          ct++;
        }
    }
  }

  cout << ct << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#define SWAP(type, a, b) {type tmp = a; a = b; b = tmp;}

int main(void) {
    int x, y;

    while (1) {
        scanf("%d %d", &x, &y);

        if (x == 0 && y == 0) break;
        if (x > y) SWAP(int, x, y);
        printf("%d %d\n", x, y);
    }
    return 0;
}


Measured memory_bytes: 2056
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
using ll = int64_t;
using VL = vector<ll>;
using VD = vector<double>;
using VVL = vector<VL>;

#define FOR(i, start, end) for(ll i = (start), (i ## xxxx_end)=(end); i < (i ## xxxx_end); ++i)
#define FORD(i, start, end) for(ll i = (start), (i ## xxxx_end)=(end); i > (i ## xxxx_end); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPD(i, n) FORD(i, n - 1, -1)

#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

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

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}

#define INF (1LL << 60)
#define MOD 1000000007LL

ll N, K;
VL A;
VVL dp, sums;

void solve() {
    cin >> N >> K;
    A = VL(N);
    for (auto &a : A) cin >> a;

    // dp[i][j]: i番目までの子供たちにj個配る場合の数
    dp = VVL(N + 1, VL(K + 1, 0));
    dp[0][0] = 1;
    // sums[i]: dp[i]の累積和
    sums = VVL(N + 1, VL(K + 2, 0));
    FOR(j, 1, K + 2)
        sums[0][j] = 1;

    FOR(i, 1, N + 1) {
        REP(j, K + 1) {
            dp[i][j] = (sums[i - 1][j + 1] - sums[i - 1][max(ll(0), j - A[i - 1])] + MOD) % MOD;
            sums[i][j + 1] = (sums[i][j] + dp[i][j]) % MOD;
        }
    }
    print(dp[N][K]);
}

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

Measured memory_bytes: 159088
#include <bits/stdc++.h>
using namespace std;
int a[10];
int main()
{
	for(int i=0;i<4;i++)
		cin>>a[i];
	sort(a,a+4);
	if(a[0]==1&&a[1]==4&&a[2]==7&&a[3]==9)
		cout<<"YES";
	else
		cout<<"NO";

	return 0;
}

Measured memory_bytes: 256
from heapq import heappush, heappop
inf = float('inf')

# import: from heapq import heappush,heappop
# distの初期化: dist = [inf]*n; dist[start] = 0
def dijkstra(ad,dist,n,start):
    pq = [(0,start)]
    while pq:
        w,v = heappop(pq)
        for nw,nv in ad[v]:
            if dist[nv] > dist[v] + nw:
                dist[nv] = dist[v] + nw
                heappush(pq,(dist[nv],nv))

N = int(input())

ad = [[] for _ in range(N)]

for _ in range(N-1):
    a,b,c = map(int,input().split())
    a -= 1;  b -= 1
    ad[a].append((c,b))
    ad[b].append((c,a))

Q,K = map(int,input().split())
K -= 1
query = [[int(e)-1 for e in input().split()] for _ in range(Q)]

dist = [inf]*N
dist[K] = 0

dijkstra(ad,dist,N,K)

for x,y in query:
    ans = dist[x] + dist[y]
    print(ans)

Measured memory_bytes: 64428
from itertools import product
import copy
h,w,k=map(int,input().split())
c = [[0]*w for i in range(h)]
for i in range(h):
    line = list(input())
    for j in range(w):
        if line[j]=='#':
            c[i][j]=1

ans = 0
for bit in product(range(2), repeat=h+w):
    cc = copy.deepcopy(c)
    #print(bit, end=' ')
    for i in range(h):
        if bit[i]==1:
            for j in range(w):
                cc[i][j] = 0
    for j in range(w):
        if bit[j+h]==1:
            for i in range(h):
                cc[i][j] = 0
    res = 0
    for i in range(h):
        res += sum(cc[i])
    #print(cc)
    if res==k:
        ans+=1
        #print('!!!!')
print(ans)

Measured memory_bytes: 77284
/*
AizuOnline A2014
Maximum Sum Sequence
*/
#include <stdio.h>
#include <string.h>

int W,H;
char a[50][51];
char b[50][51];

void printa()
{
  int i;
  for(i=0;i<H;i++)
    {
      printf("%s\n",&(a[i]));
    }
}
void printb()
{
  int i;
  for(i=0;i<H;i++)
    {
      printf("%s\n",(char *)&(b[i]));
    }
}
void fill_black2(int y,int x)
{
  //printf("%d %d\n",x,y);
  if((x < 0)||(x > W-1)||(y < 0)||(y > H-1))
    return;
  if(a[y][x]=='.')
    {
      a[y][x] = 'b';
      fill_black2(y-1,x);
      fill_black2(y+1,x);
      fill_black2(y,x-1);
      fill_black2(y,x+1);
    }
}
void fill_black()
{
  int i,j;
  for(i=0;i<H;i++)
     for(j=0;j<W;j++)
       if(a[i][j]=='B')
	 {
	   fill_black2(i-1,j);
	   fill_black2(i+1,j);
	   fill_black2(i,j-1);
	   fill_black2(i,j+1);
	 }
}
void fill_white2(int y,int x)
{
  //printf("%d %d\n",x,y);
  if((x < 0)||(x > W-1)||(y < 0)||(y > H-1))
    return;
  if(b[y][x]=='.')
    {
      b[y][x] = 'w';
      fill_white2(y-1,x);
      fill_white2(y+1,x);
      fill_white2(y,x-1);
      fill_white2(y,x+1);
    }
}
void fill_white()
{
  int i,j;
  for(i=0;i<H;i++)
     for(j=0;j<W;j++)
       if(b[i][j]=='W')
	 {
	   fill_white2(i-1,j);
	   fill_white2(i+1,j);
	   fill_white2(i,j-1);
	   fill_white2(i,j+1);
	 }
}
void mokusan()
{
  int i,j;
  int wc,bc;

  bc=wc=0;
  for(i=0;i<H;i++)
     for(j=0;j<W;j++)
       {
	 if(a[i][j]=='b' && b[i][j]== '.')
	   bc ++;
	 if(a[i][j]=='.' && b[i][j]== 'w')
	   wc ++;
       }
  printf("%d %d\n",bc,wc);
}
main()
{
  int i,j;

  while(EOF!=scanf("%d %d",&W,&H) && (W || H))
    {
     for(i=0;i<H;i++)
	{
	  scanf("%s",(char *)&(a[i]));
	  strcpy((char *)&(b[i]),(char *)&(a[i]));
	}
     fill_black();
     //printa();
     fill_white();
     //printb();
     mokusan();
     //break;
    }
return(0);
}

Measured memory_bytes: 668
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	string A, B, C;
	cin >> A >> B >> C;

	cout << A[0] << B[0] << C[0] << endl;

	Would you please return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <vector>
using namespace std;

int N;
const int MAXN = 100010;
int a[MAXN],b[MAXN];
int val[MAXN];
const long long MOD = 1e9 + 7;
int main() {
    while (scanf("%d",&N) != EOF) {
        for (int i = 0;i < N;i ++) {
            scanf("%d",&a[i]);
        }
        for (int i = 0;i < N;i ++) {
            scanf("%d",&b[i]);
        }

        memset(val,-1,sizeof(val));
        val[0] = a[0];
        val[N - 1] = b[N - 1];
        bool ok = true;
        for (int i = 0;i + 1 < N;i ++) {
            if (a[i] != a[i + 1]) {
                if (val[i + 1] == -1 || val[i + 1] == a[i + 1]) {
                    val[i + 1] = a[i + 1];
                }
                else {
                    ok = false;
                    break;
                }
            }
        }
        for (int i = N - 1;i - 1 >= 0;i --) {
            if (b[i] != b[i - 1]) {
                if (val[i - 1] == -1 || val[i - 1] == b[i - 1]) {
                    val[i - 1] = b[i - 1];
                }
                else {
                    ok = false;
                    break;
                }
            }
        }
    /*    cout << ok << endl;
        for (int i = 0;i < N;i ++) {
            cout << val[i] << " ";
        }
        cout << endl; */
        int maxs = val[0];
        for (int i = 0;i < N;i ++) {
            maxs = max(maxs,val[i]);
            if (a[i] != maxs) {
                ok = false;
        //        cout << "111" << endl;
                break;
            }

        }
        maxs = val[N - 1];
        for (int i = N - 1;i >= 0;i --) {
            maxs = max(maxs,val[i]);
            if (b[i] != maxs) {
                ok = false;
         //       cout << "222" << endl;
                break;
            }

        }

        if (!ok) {
            puts("0");
             continue;
        }
        long long ans = 1;
        for (int i = 0;i < N;i ++) {
            if (val[i] != -1) continue;
            ans = ans * min(a[i],b[i]) % MOD;
        //    cout << min(a[i],b[i]) << endl;
        }
        cout << ans << endl;
    }
}


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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

#define PB(N) push_back(N)

using namespace std;

using Graph = vector<vector<int>>;

int main(){
  int A,B; cin >> A >> B;
  cout << A*B;

  return 0;
}


Measured memory_bytes: 3632
n = int(input())
a = list(map(int,input().split()))

li = [0]*n

ans = 1
mod = 1000000007

for i in a:
    if i == 0:
        if li[0] == 0:
            ans *= 3
        elif li[0] == 1:
            ans *= 2
        elif li[0] == 2:
            ans *= 1
        else:
            ans *= 0
        li[0] += 1
    else:
        if li[i] == 0:
            if li[i-1] == 1:
                ans *= 1
            elif li[i-1] == 2:
                ans *= 2
            elif li[i-1] == 3:
                ans *= 3
            else:
                ans *= 0
        elif li[i] == 1:
            if li[i-1] == 2:
                ans *= 1
            elif li[i-1] == 3:
                ans *= 2
            else:
                ans *= 0
        elif li[i] == 2:
            if li[i-1] == 3:
                ans *= 1
            else:
                ans *= 0
        else:
            ans *= 0
        li[i] += 1
    ans %= mod

print(ans)


Measured memory_bytes: 14056
#include <bits/stdc++.h> 
#define pb push_back
#define mp make_pair 
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a,n) a, a + n
  
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;
int main()
{
int n,i,count=0;
cin>>n;
string s[n];
for(i=0;i<n;i++)
{
    cin>>s[i];
}
sort(s,s+n);
for(i=0;i<n-1;i++)
{
    if(s[i]!=s[i+1])
    count++;
}
cout<<count+1<<endl;


    return 0 ;

}

Measured memory_bytes: 9880
#include <climits>
#include <iostream>
#include <algorithm>

using namespace std;

int n;
int R[200000];
int M[200000];

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> R[i];
    }
    M[n - 1] = R[n - 1];
    for (int i = n - 2; i >= 0; i--) {
        M[i] = max(R[i], M[i + 1]);
    }
    int ans = INT_MIN;
    for (int i = 0; i < n - 1; i++) {
        ans = max(ans, M[i + 1] - R[i]);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int T;
	cin >> T;
	while(T--){
		int a=0,b=0;
		string ans = "YES";
		for(int i = 0 ; i < 10 ; i++){
			if( a > b ) swap(a,b);
			int x;
			cin >> x;
			if( x < a ){
				ans = "NO";
			}else if( b < x ){
				b = x;
			}else{
				a = x;
			}
		}
		cout << ans << endl;
	}
	
}

Measured memory_bytes: 2960
#include<stdio.h>

int main(void){
    int x, y;
    do{
        scanf("%d %d", &x, &y);
        if(x == 0 && y == 0){
            break;
        }else if(x > y){
            printf("%d %d\n", y, x);
        }else{
            printf("%d %d\n", x, y);
        }
    }while(1);
    
    return 0;
}


Measured memory_bytes: 2140
// Created by ahmed_drawy on 11/09/19.
///dp educational contest atcoder
#include <bits/stdc++.h>
#include <string.h>
#pragma clang diagnostic push
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
using namespace std;
#define lp(i,start , end)       for(int i = start ; i<end ; ++i)
#define lllp(i,start , end)       for(ll i = start ; i<end ; ++i)
#define inN(arr ,  n) for(int i = 0 ; i< n ; ++i)  cin>>arr[i];
#define Rlp(i,start , end)      for(int i = start ; i>end ; --i)
#define all(v)                   ((v).begin(),(v).end())
#define sz(v)                  (int)((v).size())
#define clr(v,d)                memset(v , d , sizeof(v))
#define inf 0x3f3f3f3f
//#define dbg (v)    for(auto it : v)cout<<it<<' ';
typedef long long               ll;
typedef vector<int>             vi;
typedef vector  <ll>            vll;
typedef vector<vector<int> >    adj;
typedef pair<int ,int>          pii;
const double EPS =1e-7;
const int OO = 1e6;
#define endl '\n'
#define cint(c) (int)c -'0';
#define itc(c) (char)c +'A';
bool sortpair( const pair<int , int> & x, const pair<int , int> & y){
    return  x.first != y.first ? x.first < y.first : x.second > y.second ;
}
int dcomp(double x , double y){
    return fabs(x-y) <= EPS? 0: x>y?1:-1;
}

void smile() {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
   // freopen("/home/tw3/Desktop/Desktop/training/in.txt", "r", stdin);
//    freopen("/home/tw3/Desktop/Desktop/training/out.txt" , "w" , stdout);
#endif
}
#define fastin smile()

int n , m;
const int N = 3000 +3;
int dp[N][N];
string s, t;
void build(int i , int j){
    if(i == n || j ==m )
        return  ;
    if(s[i] == t[j]) {
        cout << s[i];
        build(i+1, j+1);
        return ;
    }
    if(dp[i+1][j] > dp[i][j+1] )
        build(i+1, j);
    else build(i, j+1);
    return ;

}
int main() {
    fastin;
    cin >> s >> t;
    n = sz(s), m = sz(t);
    for (int i = n-1; i >=0 ; --i) {
        for (int j = m-1; j>=0 ; --j) {
            int &ret = dp[i][j];
            ret = 0;
            if(s[i] == t[j])
                ret =1 +  dp[i+1][j+1];
            else {
                ret = max(ret, dp[i + 1][j]);
                ret = max(ret, dp[i][j+1]);

            }
        }
    }
    build(0,0);


}

Measured memory_bytes: 35712
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <bitset>
#include <set>
#include <iomanip>
#include <functional>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'a' = 97

int main()
{
    char x , y;
    cin >> x >> y;
    if (x - 'A' < y - 'A') cout << '<' << endl;
    else if (x - 'A' > y - 'A') cout << '>' << endl;
    else cout << '=' << endl;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    var n = parseInt(input[0], 10);
    var astr = input[1].split(' ');
    var a = new Array(n);

    for (var i = 0; i < n; i++) {
        a[i] = parseInt(astr[i], 10);
    }

    var ans = 0;
    var or = a[0];
    for (var l = 0, r = 0; l < n; l++) {

        while ((r + 1) < n && (or & a[r + 1]) === 0) {
            or |= a[r + 1];
            r++;
        }
        ans += r - l + 1;

        or &= ~a[l];
    }

    console.log(ans);

    return 0;
}


Measured memory_bytes: 35620
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	static Main instance = new Main();

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		//入力値取得
		int N = scan.nextInt();

		long[] A = new long[N];

		for (int i = 0; i < N; i++) {
			A[i] = scan.nextLong();
		}

		//WK変数
		BigInteger result = BigInteger.valueOf(1);

		//演算
		for (int i = 0; i < N; i++) {

			if (A[i] == 0L) {
			result = BigInteger.ZERO;
			break;
			}
		}

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

			result = result.multiply(BigInteger.valueOf(A[i]));

			if (result.compareTo(BigInteger.valueOf(1000000000000000000L)) > 0) {
			result = BigInteger.ONE.negate();
			break;
			}
		}

		//結果出力
			System.out.println(result);
	}
}

Measured memory_bytes: 61664
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


x, y = map(int, input().split())
ans = 0
if ((x+y)%3 == 0):
    X = (2*x - y)//3
    Y = (2*y - x)//3
    ans = cmb(X+Y,X,mod)
print(ans)

Measured memory_bytes: 122128
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

int main(void) {
	char s[120];
	int k, sl, i;
	scanf("%d", &k);
	scanf("%s", s);
	sl = strlen(s);

	if (sl <= k) {
		printf("%s", s);
	}
	else {
		for (i = 0; i < k; i++) {
			printf("%c", s[i]);
		}
		printf("...");
	}

	return 0;
}


Measured memory_bytes: 1728
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=998244353;
const ll MAX_N=500010;
const ll INF=100100100100100;


int main(){
    int n,k;
    cin>>n>>k;
    vector<ll> v(n);
    vector<ll> sum(n+1);
    ll s=0;
    for(int i=0;i<n;i++){
        cin>>v[i];
        sum[i+1]=sum[i]+v[i];
        s+=v[i];
    }
    ll ans=-INF;
    for(int l=0;l<=n;l++){
        for(int r=0;r<=n;r++){
            if(l>r) continue;
            ll buf=0;
            int life=k;
            vector<ll> q(0);
            for(int i=0;i<l;i++){
                buf+=v[i];
                q.push_back(v[i]);
                life--;
            }
            for(int i=r;i<n;i++){
                buf+=v[i];
                q.push_back(v[i]);
                life--;
            }
            if(life<0) continue;
            sort(q.begin(), q.end());
            int m=q.size();
            for(int i=0;i<min(life,m);i++){
                if(q[i]>=0) break;
                buf-=q[i];
            }
            ans=max(ans,buf);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3192
import sys
def input():
    return sys.stdin.readline()[:-1]
N = int(input())
A = list(map(int, input().split()))
lenA = len(A)

m0 = sum([A[i] for i in range(lenA) if i%2==0]) \
   - sum([A[i] for i in range(lenA) if i%2==1])

res = [0]*lenA
res[0] = m0

last = m0
i = 1
for a in A[:-1]:
    res[i] = 2*(a-last//2)
    last = res[i]
    i += 1

print(*res)

Measured memory_bytes: 63856