akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define N 8
#define FREE -1
#define NOT_FREE 1

int col[N],row[N],dpos[N*2-1],dneg[N*2-1],B[N][N];
void putQueen(int);
void printBoard(void);
 
void putQueen(int i){
  int j;
 
  if(i == N)
  {
    printBoard();
    return;
  }
  for(j=0;j<N;j++){
    if(col[j]==NOT_FREE ||dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE){
      continue;
    }
  row[i]=j;
  col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
  putQueen(i+1);
  col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
 
  }
}
 
void printBoard(void){
  int i,j;
 
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(B[i][j]==NOT_FREE && row[i] != j)return;
    }
  }
for(i=0;i<N;i++){
  for(j=0;j<N;j++){
    if(row[i]==j)printf("Q");
    else printf(".");
    }
  printf("\n");
  }
}
 
int main(){
  int i, j, n,x,y;
scanf("%d",&n);
 
for(i=0;i<N;i++){
  row[i]=FREE;
  col[i]=FREE;
  for(j=0;j<N;j++){
    B[i][j] =0;
  }
}
 
for(i=0;i<N*2-1;i++){
  dpos[i]=FREE;
  dneg[i]=FREE;
}
 
for(i=0;i<n;i++){
  scanf("%d %d",&x,&y);
  B[x][y] = NOT_FREE;
}
putQueen(0);
 
return 0;
}

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

int main() {
    int t;
    cin >> t;
    deque<int> a;
    while (t--) {
        int q;
        cin >> q;
        if (q == 0) {
            int d, k;
            cin >> d >> k;
            if (d == 0) {
                a.push_front(k);
            } else {
                a.push_back(k);
            }
        } else if (q == 1) {
            int k;
            cin >> k;
            cout << a[k] << endl;
        } else {
            int d;
            cin >> d;
            if (d == 0) {
                a.pop_front();
            } else {
                a.pop_back();
            }
        }
    }
}


Measured memory_bytes: 4664
#include <stdio.h>

int main()
{
    char str[100];
    int n,K;
    scanf("%d",&K);
    scanf("%s", str);
    n = 0;
    while (str[n] != '\0') {  /* str[n] が終端文字（ヌル文字 '\0'）でない間繰り返す */
        n++;
    }
    //printf("Length of \"%s\" is %d.\n", str, n);
    //printf("%d %d\n",K ,n);
    if(K>=n){
        printf("%s\n",str);
        //printf("AAAA\n");
    }else{
        int i;
        for(i = 0 ;i<K; i++){
            printf("%c",str[i]);
            //printf("B\n");
        }
        printf("...");
        
    }
    
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    string s; cin >> s;
    vector<int> cnt(26);
    EACH(c, s) cnt[c-'a']++;
    int rest = 0;
    REP(i, 26) {
        rest += cnt[i] % 2;
    }
    cout << rest/2 << endl;
}

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

int main() {
  ll a,b,k;
  cin >> a >> b >> k;
  
  if(a >= k)
    cout << a-k << " " << b << endl;
  else if(a < k && b+a >= k)
    cout << 0 << " " << b-k+a << endl;
  else
    cout << 0 << " " << 0 << endl;
}

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

int main(void){
    int n;
    cin >> n;
    int count=0;
    int count2 = 0;
    int ans = 0;
    for (int i = 1; i <= n; i++){
        //何回2で割れるか
        count = 0;
        int a=i;
        while(a%2==0){
            a/=2;
            count++;
        }
        //count比較
        if (count2<count){
            count2 = count;
            ans=i;
        }
    }
    if (n==1) ans++;
    
    cout << ans << endl;
    
}

Measured memory_bytes: 256
from itertools import combinations_with_replacement

N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]

ans = 0
for A in combinations_with_replacement(range(1,M+1), N):
    pts = 0
    for a, b, c, d in abcd:
        if A[b-1] - A[a-1] == c:
            pts += d
    ans = max(ans, pts)

print(ans)

Measured memory_bytes: 67828
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    int A,B,M;
    cin>>A>>B>>M;
    int a[A],b[B];
    int ma=inf,mb=inf;
    rep(i,A){
        cin>>a[i];
        ma=min(ma,a[i]);
    }
    rep(i,B){
        cin>>b[i];
        mb=min(mb,b[i]);
    }
    int ans=ma+mb;
    rep(i,M){
        int x,y,c;
        cin>>x>>y>>c;
        --x,--y;
        ans=min(ans,a[x]+b[y]-c);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstring> 
using namespace std;
typedef long long ll;
const int N=1e5+2;;
const int inf =1e6;
int  n,d;
int a[N];

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>d;
		a[d]=i;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<a[i]<<" "; 
	}
	
} 

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

#define ll long long
#define ld long double
#define mod 1000000007LL
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define endl '\n'
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mp make_pair
#define pb(x) push_back(x)
#define fo(i, a, n) for (i = (a); i < (n); i++)
#define foe(i, a, n) for (i = (a); i <= (n); i++)
// clang-format off
#define vin(a) for (ll i = 0; i < sz(a); i++) { cin >> a[i]; } 
#define vout(a) for (auto x : a) { cout << x << " "; }
#define sws                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0)
// clang-format on
#define pd(x) cout << x
#define sd(x) cin >> x
#define nl cout << endl
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define foreach(i, a)                                                          \
  for (__typeof((a).begin()) i = (a).begin(); i != (a).end(); ++i)
#define sz(a) (int)((a).size())
// int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
void solve() {
  ll m, n;
  ll i, j;
  cin >> n;
  vll a(n), ssum(n);
  vin(a);

  ssum[n - 1] = 0;
  for (i = n - 2; i >= 0; i--) {
    ssum[i] = ssum[i + 1] + a[i + 1];
    ssum[i] %= mod;
  }

  ll ans = 0;
  fo(i, 0, n) { ans = (ans + a[i] * ssum[i]) % mod; }

  cout << ans << endl;
}

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

Measured memory_bytes: 6348
h, w, k = gets.split.map(&:to_i)
cakes = Array.new
h.times do
  cakes << gets.chomp.split("")
end
strawberries = cakes.map { |cake| cake.count("#") }
cut_cakes = Array.new(h) { Array.new(w) }
current_num = 0
strawberries.each_with_index do |strawberry ,index|
  if strawberry > 0
    current_num += 1
    next_change = false
    current_s = 0
    cakes[index].each_with_index do |piece, index2|
      if next_change
        current_num += 1
      end
      cut_cakes[index][index2] = current_num
      if piece == "#" && current_s < strawberry - 1
        next_change = true
        current_s += 1
      else
        next_change = false
      end
    end
  end
end

first_nonzero = strawberries.find_index { |i| i > 0 }
(first_nonzero + 1).upto(h - 1) do |index|
  if strawberries[index] == 0
    cut_cakes[index] = cut_cakes[index - 1]
  end
end

(first_nonzero - 1).downto(0) do |index|
  if strawberries[index] == 0
    cut_cakes[index] = cut_cakes[index + 1]
  end
end

cut_cakes.each do |cut_cake|
  puts cut_cake.join(" ")
end


Measured memory_bytes: 11772
n,m = gets.split.map(&:to_i)
arrayL = Array.new
arrayR = Array.new
m.times do
  l,r = gets.split.map(&:to_i)
  arrayL << l
  arrayR << r
end


if arrayL.max > arrayR.min
  puts 0
elsif arrayL.max == arrayR.min
  puts 1
else
  puts arrayR.min - arrayL.max + 1
end

Measured memory_bytes: 3464
n, m = (int(i) for i in input().split())
a,b = [0 for i in range(m)],[0 for i in range(m)]
g = [[] for i in range(n)]
OK = False 
for i in range(m):
    a[i],b[i] = map(int, input().split())
    a[i]-=1
    b[i]-=1
    g[a[i]].append(b[i])
    g[b[i]].append(a[i])
for i in range(m):
    if a[i]==0 and n-1 in g[b[i]]:
        OK = True
print('POSSIBLE' if OK else 'IMPOSSIBLE')


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

int func ( string s, string t ) {
  int ans = 0;
  for ( char c = 'a'; c <= 'z'; c++ ) {
    bool founds = false,foundt = false;
    for ( int i = 0; i < s.length(); i++ ) {
      if ( s[i] == c ) founds = true;
    }
    for ( int i = 0; i < t.length(); i++ ) {
      if ( t[i] == c ) foundt = true;
    }
    if ( founds == true && foundt == true ) ans++;
  }
  return ans;
}

int main() {
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for ( int i = 0; i <= N; i++ ) {
    int tmp = func(S.substr(0,i),S.substr(i));
    ans = max(tmp,ans);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;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--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

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

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

void Main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll ans = B - (A - 1);
    ll lcm_cd = lcm(C, D);
    ans -= (B / C) - ((A - 1) / C);
    ans -= (B / D) - ((A - 1) / D);
    ans += (B / lcm_cd) - ((A - 1) / lcm_cd);
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define MP make_pair
#define pb push_back

using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef long long LL;

static const int INF = INT_MAX;
static const LL L_INF = LLONG_MAX;
static const int MOD = (1000000000 + 7);

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

    while( true ) {
        int x, y;
        cin >> x >> y;
        if( !x && !y ) break;
        if( x > y ) swap(x, y);
        cout << x << " " << y << endl;
    }

    return 0;
}


Measured memory_bytes: 3132
#ifndef LOCAL
#pragma GCC optimize("Ofast")
#endif

#include "bits/stdc++.h"

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ld = long double;

constexpr int nax = 1000 + 105;
constexpr int infty = 1000 * 1000 * 1000 + 5;
constexpr int mod = 1000 * 1000 * 1000 + 7;

int n, k;
int ile[2][nax][nax];

int Licz(int c, int x, int y) {
  int wynik = ile[c][k - 1][k - 1] + ile[c][x][y] * 2;
  wynik -= ile[c][k - 1][y];
  wynik -= ile[c][x][k - 1];
  //debug() << "Licz(" imie(c) imie(x) imie(y) ") = " << wynik;
  return wynik;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int x, y;
    char c;
    cin >> x >> y >> c;
    assert(c == 'W' or c == 'B');
    const int px = (x / k) % 2;
    const int py = (y / k) % 2;
    int kolor = (c == 'B');
    kolor ^= (px + py) % 2;
    ile[kolor][x % k][y % k]++;
    debug() << imie(kolor) imie(x % k) imie(y % k);
  }
  for (int c = 0; c < 2; c++) {
    for (int i = 0; i < k; i++) {
      for (int j = 0; j < k; j++) {
        if (i) ile[c][i][j] += ile[c][i - 1][j];
        if (j) ile[c][i][j] += ile[c][i][j - 1];
        if (i and j) ile[c][i][j] -= ile[c][i - 1][j - 1];
        //debug() << imie(c) imie(i) imie(j) imie(ile[c][i][j]);
      }
    }
  }
  int wynik = 0;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < k; j++) {
      const int jed = Licz(0, i, j);
      const int dwa = Licz(1, i, j);
      wynik = max(wynik, max(jed + ile[1][k - 1][k - 1] - dwa, dwa + ile[0][k - 1][k - 1] - jed));
    }
  }
  cout << wynik << endl;
  return 0;
}


Measured memory_bytes: 9344
n,k=map(int,input().split())
x=list(map(int,input().split()))
ans=10**9
for i in range(n-k+1):
    l=x[i]
    r=x[i+k-1]
    a=abs(l)+abs(l-r)
    b=abs(r)+abs(l-r)
    c=min(a,b)
    ans=min(c,ans)
print(ans)

Measured memory_bytes: 14228
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
typedef long long int ll;
typedef long double ld;
const ll INF = (1 << 31) - 1;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
const int MAX = 510000;
const ll MOD = 1000000007;
int ans = -INF, n, p[100][11];
bool f[100][10];
int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) for (int j = 0; j < 10; ++j) cin >> f[i][j];
	for (int i = 0; i < n; ++i) for (int j = 0; j <= 10; ++j) cin >> p[i][j];

	for (int b = 1; b < (1 << 10); ++b) {
		bitset<10> bit = b;
		int benefit = 0;
		for (int i = 0; i < n; ++i) {
			int d = 0;
			for (int j = 0; j < 10; ++j) if (bit[9 - j] && f[i][j]) d++;
			benefit += p[i][d];
		}
		ans = max(ans, benefit);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
typedef struct{
  int parent,left,right;
}Node;

Node T[MAX];
int n, dep[MAX],hei[MAX];

void setdep(int value,int p){
  if(value==-1)return;
  dep[value]=p;
  setdep(T[value].left,p+1);
  setdep(T[value].right,p+1);
}

int sethei(int value){
  int hl=0,hr=0;
  if(T[value].left!=-1){
    hl=sethei(T[value].left)+1;
  }
  if(T[value].right!=-1){
    hr=sethei(T[value].right)+1;
  }

  if(hl>hr)return hei[value]=hl;
  else return hei[value]=hr;
}

int getsib(int value){
  if(T[value].parent==-1)return -1;
  if(T[T[value].parent].left!=value && T[T[value].parent].left!=-1)return T[T[value].parent].left;
  if(T[T[value].parent].right!=value && T[T[value].parent].right!=-1)return T[T[value].parent].right;
  return -1;
}

void print(int value){
  int d=0;
  printf("node %d: parent = %d, sibling = %d, ",value,T[value].parent,getsib(value));
  if(T[value].left!=-1)d++;
  if(T[value].right!=-1)d++;
  printf("degree = %d, depth = %d, height = %d, ",d,dep[value],hei[value]);
  if(T[value].parent==-1){
    printf("root\n");
  }
  else if(T[value].left==-1 && T[value].right==-1){
    printf("leaf\n");
  }
  else printf("internal node\n");
}

int main(){
  int i,id,left,right,root=0;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].parent=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&left,&right);
    T[id].left=left;
    T[id].right=right;
    if(left!=-1)T[left].parent=id;
    if(right!=-1)T[right].parent=id;
  }
  for(i=0;i<n;i++){
    if(T[i].parent==-1)root=i;
  }
  setdep(root,0);
  sethei(root);
  for(i=0;i<n;i++)print(i);
  return 0;
}
    
	   
      



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

pair<int, int> edge[100010];
vector<int> idx[100010];
bool tree[100010];
bool visited[100010];
int deg[100010];

void dfs(int from, int par) {
	visited[from] = true;
	for(int to_idx : idx[from]) {
		int to = edge[to_idx].first;
		if(to == from) {
			to = edge[to_idx].second;
		}
		if(to == par) continue;
		if(visited[to]) continue;
		tree[to_idx] = true;
		dfs(to, from);
	}
}

void dfs1(int from, int par) {
	for(int to_idx : idx[from]) {
		if(not tree[to_idx]) continue;
		int to = edge[to_idx].first;
		if(to == from) {
			to = edge[to_idx].second;
		}
		if(to == par) continue;
		dfs1(to, from);
	}
	if(from == 1) return;
	if(deg[from] % 2 != 0) {
		deg[from]++;
		cout << from << " " << par << '\n';
	} else {
		deg[par]++;
		cout << par << " " << from << '\n';
	}
}

int main() {
	int n, m; cin >> n >> m;
	if(m % 2 != 0) {
		cout << -1 << '\n';
		return 0;
	}
	for(int i = 0; i < m; ++i) {
		int a, b; cin >> a >> b;
		edge[i] = {a, b};
		idx[a].push_back(i);
		idx[b].push_back(i);
	}
	dfs(1, -1);
	for(int i = 0; i < m; ++i) {
		if(not tree[i]) {
			cout << edge[i].first << " " << edge[i].second << '\n';
			deg[edge[i].first]++;
		}
	}
	dfs1(1, -1);
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    for (int i=0; i < 25; i++) {
        for (int j=0; j <= 25 - i; j++) {
            if (i * 4 + j * 7 == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

bool search(int array[], int length, int key)
{
    int left = 0;
    int right = length;
    int mid;
    while (left < right)
    {
        mid = (left + right) / 2;
        if (array[mid] == key)
        {
            return true;
        }
        else if (key < array[mid])
        {
            right = mid;
        }
        else
        {
            left = mid + 1;
        }
    }
    return false;
}

int main()
{
    int baseArrayNum;
    cin >> baseArrayNum;
    int baseArray[baseArrayNum];

    for (int i = 0; i < baseArrayNum; i++)
    {
        cin >> baseArray[i];
    }

    int targetArrayNum;
    cin >> targetArrayNum;
    int targetArray[targetArrayNum];

    for (int i = 0; i < targetArrayNum; i++)
    {
        cin >> targetArray[i];
    }

    int counter = 0;
    for (int i = 0; i < targetArrayNum; i++)
    {
        int key = targetArray[i];
        if (search(baseArray, baseArrayNum, key))
        {
            counter++;
        }
    }
    cout << counter << endl;
}



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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int[] a = new int[5];
        int ans = 0;
        int x = 10;
        for(int i = 0; i < 5; i++) {
            a[i] = Integer.parseInt(br.readLine());
            ans += Math.ceil(1.0 * a[i] / 10) * 10;
            int tmp = a[i] % 10;
            if(tmp == 0) continue;
            x = Math.min(x, tmp);
        }

        System.out.println(ans - 10 + x);
    }
}

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

using namespace std;

int main(){
  string s;
  cin>>s;
  if(s=="Sunny"){
    cout<<"Cloudy"<<endl;
  }
  else if(s=="Cloudy"){
    cout<<"Rainy"<<endl;
  }
  else if(s=="Rainy"){
    cout<<"Sunny"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}


ll a[4][2020][2020]={};

int main(void) {
  ll H, W;
  cin >> H >> W;
  string s[2020];
  ll i, j;
  
  
  s[0]=string(W+2, '#');
  s[H+1]=string(W+2, '#');
  for(i=1; i<=H; i++) {
    cin >> s[i];
    s[i]='#'+s[i]+'#';
  }
  
  //自分より左0
  for(i=1; i<=H; i++) {
    for(j=1; j<=W; j++) {
      if(s[i][j]=='#') continue;
      
      a[0][i][j]=a[0][i][j-1]+1;
    }
  }
  
  //自分より右2
  for(i=1; i<=H; i++) {
    for(j=W; j>=1; j--) {
      if(s[i][j]=='#') continue;
      
      a[2][i][j]=a[2][i][j+1]+1;
    }
  }
  
  //自分より上1
  for(i=1; i<=H; i++) {
    for(j=1; j<=W; j++) {
      if(s[i][j]=='#') continue;
      
      a[1][i][j]=a[1][i-1][j]+1;
    }
  }
  
  //自分より下3
  for(i=H; i>=1; i--) {
    for(j=1; j<=W; j++) {
      if(s[i][j]=='#') continue;
      
      a[3][i][j]=a[3][i+1][j]+1;
    }
  }
  
  ll ans=0;
  for(i=1; i<=H; i++) {
    for(j=1; j<=W; j++) {
      if(s[i][j]=='#') continue;
      
      ll t=0;
      for(ll k=0; k<4; k++) {
        t+=a[k][i][j];
      }
      
      chmax(ans, t-3);
      
    }
  }
  
  pt(ans);
  
}
  
  


Measured memory_bytes: 135424
#include <cstdio>//C语言io
#include <cstring>//以下是c语言常用头文件
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>
#include <cmath>
#include <iostream>//c++IO
#include <sstream>
#include <string>
#include <list>//c++常用容器
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>//c++泛型的一些函数
#include <functional>//用来提供一些模版
#define fo0(i,n) for(int i = 0;i < n; ++i)
#define fo1(i,n) for(int i = 1;i <= n; ++i)
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF =0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
//......................................................
const int LEN = 1e5+100;
int ar[LEN];
int main(void)
{
    int n;
    while(cin>>n)
    {
        for(int i = 1; i <= n; ++i)
            scanf("%d",&ar[i]);
        int sum = 0;
        for(int i = 1; i <= n; ++i)
        {
            if(ar[i]!=i)
                continue;
            swap(ar[i],ar[i+1]);
            sum++;
        }
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 640
input_num = int(input())
dic = {}
strlist = []
strlist2 = []
maxi = 1
for i in range(input_num):
  strlist.append(input())
for i in range(input_num):
  if dic.setdefault(strlist[i],0) != 0:
    dic[strlist[i]] += 1
    if dic[strlist[i]] > maxi:
      maxi = dic[strlist[i]]
  else:
    dic[strlist[i]] = 1
    strlist2.append(strlist[i])
strlist2.sort()
for i in range(len(strlist2)):
  if dic[strlist2[i]] == maxi:
    print(strlist2[i])

Measured memory_bytes: 36396
#include<iostream>
#include<set>
using namespace std;
#define rep(i, c) for(int i=0; i<(int)c; i++)

int main(){
    int N;
    cin >> N;
    int P[N];
    rep(i, N) cin >> P[i];


    if(N==1){
        cout << 1 <<"\n";
    }
    else{
        set<int> S;
        S.insert(P[0]);
        int ans=1;

        for(int i=1; i<N; i++){
            S.insert(P[i]);
            int p;
            p = *S.begin();
            if(p==P[i]){
                ans++;
            }
        }
        cout << ans << "\n";
    }



    return 0;
}

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

        int sum = 0;
        for (int i=1; i<=N; i++) {
            int n = i;
            int digSum = 0;
            while (n > 0) {
                digSum += n % 10;
                n /= 10;
            }
            if (digSum >= A && digSum <= B)
                sum += i;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 27092
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define repeat(i,a,b) for(int i=(a),i##__end=(b);i<i##__end;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,i##__end=(a);i>=i##__end;i--)
#define mst(a,x) memset((a),(x),sizeof(a))
#define pii pair<int,int>
#define maxn 1000010
#define mod 2147483647
#define int ll
signed main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;
	cin>>n;
	int ans=1e13;
	repeat(i,1,sqrt(n+0.5)+1){
		if(n%i==0){
			ans=min(ans,n/i+i);
		}
	}
	cout<<ans-2<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e3 + 5;
const int W = 2e4 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

struct node{
	int w, s, v;
}a[N];

bool cmp(node x, node y){
	return x.w + x.s < y.w + y.s;
}

int dp[N][W];
 
signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n;	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i].w >> a[i].s >> a[i].v;
	}	
	sort(a + 1, a + n + 1, cmp);
	for(int i = 1; i <= n; i++){
		for(int x = 0; x < W; x++){
			dp[i][x] = max(dp[i-1][x], dp[i][x]);
			if(a[i].s >= x && x+a[i].w < W)
				dp[i][x+a[i].w] = max(dp[i][x+a[i].w], dp[i-1][x] + a[i].v);
		}
	}
	int ans = 0;
	for(int i = 0; i < W; i++)
		ans = max(ans, dp[n][i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 156672
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  double PI = acos(-1.0);
  int n; read(n);
  printf("%.10lf\n", PI * 2.0 * n);
  
  return 0;
}

// created by Daniel yuan


Measured memory_bytes: 3760
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout<<fixed<<setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	int p, q;
	while (scanf("%d %d", &p, &q) != EOF) {
		map<ll, ll>idx;
		idx[p] = 0;
		ll a = p * 10;
		ll dev = a / q;
		cout << dev;
		ll len = 1;
		ll b = dev * q;
		ll caret;
		bool devidable = true;
		while (true) {
			a = a - b;
			if (a == 0) {
				break;
			}if (idx.count(a) == 1) {
				caret = len - idx[a];
				devidable = false;
				break;
			} else {
				idx[a] = len;
				a *= 10;
				dev = a / q;
				cout << dev;
				++len;
				b = dev * q;
			}
		}
		if (!devidable) {
			cout << endl;
			REP(i, len - caret) {
				cout << ' ';
			}
			REP(i, caret) {
				cout << '^';
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 3136
#include <iostream>
using namespace std;
bool p(int n) {
  if (n == 2) return true;
  if (n % 2 == 0) return false;
  for (int i = 3; i * i < n; i += 2)
    if(n % i == 0) return false;
  return true;
}
int main() {
  int i, n;
  while (cin >> n) {
    for (i = n - 1; ; i--) if (p(i)) { cout << i << ' '; break; }
    for (i = n + 1; ; i++) if (p(i)) { cout << i << endl; break; }
  }
}

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

int main() {
  int A,B,C,X,Y;
  cin>>A>>B>>C>>X>>Y;
  
  int total=0;
  if(2*C<A+B) {
      int small=min(X,Y);
      total+=small*2*C;
      X-=small; Y-=small;
  }

  if(2*C<A) total+=X*2*C;
  else total+=X*A;

  if(2*C<B) total+=Y*2*C;
  else total+=Y*B;

  cout<<total<<endl;
  
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    static int gcd(int a, int b) {
        if (a % b != 0) {
            return gcd(b, a % b);
        } else {
            return b;
        }

    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int count = 0;
        int n = sc.nextInt();
        int b = sc.nextInt();
        if (n % 2 == 1 && b % 2 == 1) {
            System.out.println("Yes");
        } else
            System.out.println("No");
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

int main()
{
    int N;
    cin >> N;
    vector<ll> values(N);
    rep(i, 0, N) cin >> values[i];

    sort(values.rbegin(), values.rend());

    ll ret = values[0];
    N -= 2;
    int pos = 1;
    while (N > 0)
    {
        ll now_cnt = min(N, 2);
        ret += now_cnt * values[pos];
        // printf("pos: %d, N: %d, now: %d\n", pos, N, now_cnt*values[pos]);

        // move to next
        ++pos;
        N -= now_cnt;

    }
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 4784
{-# LANGUAGE FlexibleContexts, BangPatterns #-}

module Main where

import Data.Char
import Data.List
import Control.Monad
import Control.Monad.ST
import Data.Array.ST
import Data.Array.Unboxed
import Control.Applicative
import Text.Printf


readInt :: IO Integer
readInt = read <$> (input `seq` input)
    where input = do
            !c <- getChar
            if isDigit c || c == '-'
                then (c :) <$> input
                else return []

prints :: Show a => [a] -> IO ()
prints as = putStrLn $ concat $ intersperse " " $ map show as

f n | n < 10 = n
    | otherwise = mod n 10 + f (div n 10)

main = do
    n <- readInt
    if n == 0 then return () else print (f n) >> main


Measured memory_bytes: 4312
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
const int N=2e5+5;
set<int> g[N],s;
int a[N],b[N],u[N];
char c[N];
void ae(int x,int y){
    if(g[x].count(y))return;
    g[x].insert(y);
    if(c[y]=='A')a[x]++;
    if(c[y]=='B')b[x]++;
}
void chk(int x){
    if(!a[x]||!b[x])
        s.insert(x);
}
int tot;
void del(int x){
    tot--;
    u[x]=1;
    s.erase(x);
    for(int to:g[x]){
        if(to==x)continue;
        g[to].erase(x);
        if(c[x]=='A')--a[to];
        if(c[x]=='B')--b[to];
        chk(to);
    }
    g[x].clear();
}
int32_t main(){
    int n,m;
    cin>>n>>m;tot=n;
    forn(i,n)cin>>c[i+1];
    forn(i,m){
        int x,y;
        cin>>x>>y;
        ae(x,y);ae(y,x);
    }
    for(int i=1;i<=n;++i){
        if(!u[i]&&(!a[i]||!b[i]))del(i);
        while(!s.empty())del(*s.begin());
    }
    if(tot)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 35392
#include <bits/stdc++.h>
#define pb push_back
#define ll long long 
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1; 
    for(int T = 0; T < t ; T++){
        ll n, ans = 0, k;
        cin >> n;
        ll a[n];
        for(int i = 0 ; i < n ; i++){
            cin >> a[i];
        }
        ll pre[n], suf[n];
        pre[0] = 0, suf[n - 1] = 0;
        for(int i = 1; i < n; i++){
            pre[i] = pre[i - 1]^a[i - 1];
        }
        for(int i = n - 2; i >= 0; i--){
            suf[i] = suf[i + 1]^a[i + 1];
        }
        for(int i = 0; i < n; i++){
            cout << (pre[i]^suf[i]) << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 8228
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
 
int N,M,K;
int D[16];
int to[100][100];
int dist[1<<16];
const int INF=1001001001;
bool ok[100];
signed main(){
    cin>>N>>M>>K;
    rep(i,M)cin>>D[i],D[i]--;
    rep(i,N)rep(j,K)cin>>to[i][j],to[i][j]--;
 
    fill_n(ok,N,true);
    rep(i,M)ok[D[i]]=false;
 
    fill_n(dist,1<<M,INF);
    dist[(1<<M)-1]=0;
    queue<int>que;que.push((1<<M)-1);
    while(que.size()){
        int b=que.front();que.pop();
        rep(i,K){
            int nb=0;
            rep(j,M){
                if((b>>j&1)==0)continue;
                int nex=to[D[j]][i];
                if(ok[nex])continue;
                nex=find(D,D+M,nex)-D;
                nb|=(1<<nex);
            }
            if(dist[nb]<=dist[b]+1)continue;
            dist[nb]=dist[b]+1;
            que.push(nb);
        }
    }
    cout<<dist[0]<<endl;
    return 0;
}

Measured memory_bytes: 3892
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
vector<ll> node[10005],rnode[10005],n2[10005],rn2[10005];
vector<P> edge;
bool used[10005];
int cmp[10005];
int n,m;
vector<int> vs;
void dfs(int v){
  used[v]=true;
  for(int i=0;i<node[v].size();i++){
    int to=node[v][i];
    if(!used[to]){
      used[to]=true;
      dfs(to);
    }
  }
  vs.push_back(v);
}
void rdfs(int v,int k){
  //cout<<"RDFS:"<<v<<" "<<k<<endl;
  used[v]=true;
  cmp[v]=k;
  for(int i=0;i<rnode[v].size();i++){
    int to=rnode[v][i];
    if(!used[to]){
      used[to]=true;
      rdfs(to,k);
    }
  }
}
int scc(){
  for(int i=0;i<10005;i++)used[i]=false;
  for(int i=0;i<n;i++){
    if(!used[i]){
      used[i]=true;
      dfs(i);
    }
  }
  for(int i=0;i<10005;i++) used[i]=false;
  int k=0;
  for(int i=vs.size()-1;i>=0;i--){
    if(!used[vs[i]]) {
      used[vs[i]]=true;
      rdfs(vs[i],k);
      k++;
    //  cout<<"I7::::";
    }
    //cout<<vs[i]<<endl;
  }
  for(int i=0;i<m;i++){
    int s=edge[i].first,t=edge[i].second;
    s=cmp[s];
    t=cmp[t];
    if(s!=t){
      n2[s].push_back(t);
      rn2[t].push_back(s);
    }
  }
  int st=0,gt=0;
  for(int i=0;i<k;i++){
    if(n2[i].size()==0) st++;
    if(rn2[i].size()==0) gt++;
  }
  return (k==1?0:max(st,gt));
}
int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int s,t;
    cin>>s>>t;
    edge.push_back(P(s,t));
    node[s].push_back(t);
    rnode[t].push_back(s);
  }
  cout<<scc()<<endl;

}



Measured memory_bytes: 10740
C = []

for i in range(3):
    C.append(list(map(int, input().split())))

flg = True

for i in range(2):
    for j in range(2):
        if C[i][j+1] - C[i][j] != C[i+1][j+1] - C[i+1][j]:
            flg = False
            break
        elif C[i+1][j] - C[i][j] != C[i+1][j+1] - C[i][j+1]:
            flg = False
            break

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

Measured memory_bytes: 3064
#include<iostream>
#include<string>
using namespace std;
int main() {
	int n; cin >> n;
	for (int j = 0; j < n; j++){
		string s; cin >> s;
		char c;
		int num = 0;
		for (int i = 0; i != s.size(); i++){
			if (i == 0 || s[i - 1] == '0') {
				if (s[i] == '0')goto cont;
				else {
					c = s[i]; 
					num++;
				}
			}
			else{
				if (s[i] == '0') {
					if (c == '1') {
						num = num % 5;
						if (num == 1)cout << '.';
						else if (num == 2)cout << ',';
						else if (num == 3)cout << '!';
						else if (num == 4)cout << '?';
						else cout << ' ';
					}
					else if (c == '2') {
						num = num % 3;
						if (num == 1)cout << 'a';
						else if (num == 2)cout << 'b';
						else cout << 'c';
					}
					else if (c == '3') {
						num = num % 3;
						if (num == 1)cout << 'd';
						else if (num == 2)cout << 'e';
						else cout << 'f';
					}
					else if (c == '4') {
						num = num % 3;
						if (num == 1)cout << 'g';
						else if (num == 2)cout << 'h';
						else cout << 'i';
					}
					else if (c == '5') {
						num = num % 3;
						if (num == 1)cout << 'j';
						else if (num == 2)cout << 'k';
						else cout << 'l';
					}
					else if (c == '6') {
						num = num % 3;
						if (num == 1)cout << 'm';
						else if (num == 2)cout << 'n';
						else cout << 'o';
					}
					else if (c == '7') {
						num = num % 4;
						if (num == 1)cout << 'p';
						else if (num == 2)cout << 'q';
						else if (num == 3)cout << 'r';
						else cout << 's';
					}
					else if (c == '8') {
						num = num % 3;
						if (num == 1)cout << 't';
						else if (num == 2)cout << 'u';
						else cout << 'v';
					}
					else if (c == '9') {
						num = num % 4;
						if (num == 1)cout << 'w';
						else if (num == 2)cout << 'x';
						else if (num == 3)cout << 'y';
						else cout << 'z';
					}
					num = 0;
				}
				else num++;
			}
		cont:;
		}
		cout << endl;
	}
}

Measured memory_bytes: 3052
n, result = map(int, input().split())
 
for x in range(n + 1):
  for y in range(n - x + 1):
    if 10000 * x + 5000 * y + 1000 * (n - x - y) == result:
      print(x, y, (n - x - y))
      exit()
 
print("-1 -1 -1")

Measured memory_bytes: 3060
#create date: 2020-04-04 21:06

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n, m = na()
    a = na()
    k = 1/(4*m) * sum(a)
    a.sort(reverse=True)
    if a[m-1] >= k:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
#include<stack>
#include<queue>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;

int main(){
  double n, x, ans = 0;
  string s;
  cin >> n;
  rep(i, n){
      cin >> x >> s;
      if(s == "JPY") ans += x;
      else ans += 380000 * x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a[10010];
    int n,m;

    int total;

    scanf("%d%d", &n, &m);

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

    if(n < total){
        printf("-1\n");
    }else{
        printf("%d\n", n-total);
    }
}

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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    COMinit();
    int N, K; cin >> N >> K;

    for (int k = 1; k <= K; k++) {
        if (k > N - K + 1) {
            cout << 0 << endl;
            continue;
        }

        long long pat_b = COM(K - 1, k - 1);
        long long pat_r = (
            (2 * COM(N - K - 1, k - 1) % MOD + COM(N - K - 1, k)) % MOD
            + COM(N - K - 1, k - 2)
        ) % MOD;
        if (N == K && k == 1) pat_r = 1;

        cout << pat_b * pat_r % MOD << endl;
            
    }

}


Measured memory_bytes: 12160
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
struct edge { int to;  int cost; };
int x[200006];
int rwa[200006];
vector<int>G[200006];
vector<int>V;
signed main() {
	int n, X; cin >> n >> X;
	rep(i, n)cin >> x[i];
	rep(i, n)rwa[i + 1] = x[i];
	rep(i, n)rwa[i + 1] += rwa[i];
	int ans = inf;
	int s1 = 0;

	for(int i=1;i<=n;i++){//i台
		int sum = i*X + n*X;
		s1 += x[n - i]*5;
		sum += s1;
		
		for (int j = n - 1; j >= 0; j -= i) {
			int r = j, l = j - i + 1;
			l = max(l, 0ll);
			int p = (n - 1 - j) / i;
			if (p) {
				p = 2 * p + 3;
				sum += p*(rwa[r + 1] - rwa[l]);
			}
		}
		if (sum < 0)sum = inf;
		ans = min(ans, sum);
	}
	cout << ans << endl;
}

Measured memory_bytes: 8064
F = [0 for i in range(50)]
F[0] = 1
F[1] = 1

def fib(n) :
    if n == 0 or n == 1:
        F[n] = 1
        return F[n]
    else:
        if F[n] == 0:
            F[n] = fib(n-1) + fib(n-2)
            return F[n]
        else:
            return F[n]
n = int(input())
print(fib(n))


Measured memory_bytes: 5600
#include<iostream>

using namespace std;

int main( )
{
	char str[1201];
	int i;
	
	
	cin.getline(  str, sizeof( str ) );
	
	for( i=0; '\0'!=str[i]; i++ ) {
		if( 'A'<=str[i] && str[i]<='Z' ) {
			str[i] += 32;
		} else if(  'a'<=str[i] && str[i]<='z'  ) {
			str[i] -= 32;
		} 
	}
	str[i]='\0';
	
	cout<<str<<endl;
	
	return 0;
}

Measured memory_bytes: 1128
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let n = read::<i64>();
  let mut up = vec![];
  let mut down = vec![];
  let mut memo: Vec<i64> = vec![0; n as usize];

  for _ in 0..n {
    up.push(read::<i64>())
  }
  for _ in 0..n {
    down.push(read::<i64>())
  }

  for i in 0..n {
    let up_sub = &up[..i as usize + 1];
    let down_sub = &down[i as usize..];
    let mut total = 0;
    for i in up_sub {
      total += *i
    }
    for i in down_sub {
      total += *i
    }
    memo[i as usize] = total;
  }

  println!("{:?}", memo.iter().max().unwrap());
}


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

double pgauss(double a){
    int b;
    b = a;
    if(a==b) return b;
    return b+1;
}

int main(void){
    int n,k,a,i;
    double b,p=0;
    scanf("%d%d",&n,&k);
    
    for(i=0;i<n;i++){
        if(i+1>=k){
            p += (double) 1/n;
            continue;
        }
        b = (double) k/(i+1);
        a = pgauss(log2(b));
        p += 1/pow(2,a)/n;
    } 
    printf("%.12f\n",p);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int a = scanner.nextInt();
		    int b = scanner.nextInt();
		    int c = scanner.nextInt();
		    int d = scanner.nextInt();
		    
		    System.out.println(Math.min(a, b) + Math.min(c, d));
		    
		    scanner.close(); }
		  }

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int sum = 0;
  
  for (int i = 0; i < N; i++){
    int x;
    cin >> x;
    
    if (x <= K - x){
      sum += x * 2;
    }
    
    else if (x > K - x){
      sum += (K - x) * 2;
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
const int INF = 1000100100;


int main(){
    ll n,k,a[200005],cnt=0,ans;
    string s;
    cin>>n;
    cin>>s;
    rep(i,n){
        if(s[i]=='W'){
            cnt++;
            if(i>0){
                a[i]=a[i-1]+1;
            }else{
                a[0]=1;
            }
        }else{
            if(i>0){
                a[i]=a[i-1];
            }else{
                a[0]=0;
            }
        }
    }
    if(cnt==n){
        ans=0;
    }else{
        ans=a[n-cnt-1];
    }
    cout<<ans;
}

Measured memory_bytes: 5304
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

H,W=get_i
N=gets.to_i
A=get_i
ans=array(W,-1,H)
f=true
i=0
j=0
A.each_with_index do|a,c|
    a.times do|k|
        ans[i][j]=c+1
        if f
            j+=1
            if j==W
                f=false
                j=W-1
                i+=1
            end
        else
            j-=1
            if j==-1
                f=true
                j=0
                i+=1
            end
        end
    end
end
H.times do|i|
    puts ans[i].join(" ")
end

Measured memory_bytes: 14980