akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1LL<<60;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

struct Node {
    int key;
    Node* parent;
    Node* left;
    Node* right;
};

// 新しいノードを作成
Node* new_node(int key) {
    Node* node = new Node;
    node->key = key;
    node->parent = NULL;
    node->left = NULL;
    node->right = NULL;
    return node;
}

// ノードが属する木の根を再帰的に求める
Node* root(Node* node) {
    if (!node->parent) return node;
    else return root(node->parent);
}

// 木にノードを挿入する
void insert(Node* tree, int key) {
    Node* now = root(tree);  // 木の根
    Node* par = NULL;        // nowの親
    Node* z = new_node(key); // 挿入するノード

    // 根から下へ辿り挿入する場所を求める
    while (now) {
        par = now;
        if (z->key < now->key) {
            now = now->left;
        } else {
            now = now->right;
        }
    }
    z->parent = par;

    if (!par) {
        tree = z;
    } else if (key < par->key) {
        par->left = z;
    } else {
        par->right = z;
    }
}

bool find(Node* tree, int key) {
    Node* now = root(tree);
    while (now) {
        if (now->key == key) return true;
        else if (key < now->key) {
            now = now->left;
        } else {
            now = now->right;
        }
    }
    return false;
}

void inorder(Node* tree) {
    if (!tree) return;
    inorder(tree->left);
    cout << " " << tree->key;
    inorder(tree->right);
}

void preorder(Node* tree) {
    if (!tree) return;
    cout << " " << tree->key;
    preorder(tree->left);
    preorder(tree->right);
}

int main() {
    int n; cin >> n;
    Node* tree;
    rep(i, n) {
        string query; cin >> query;
        if (query == "insert") {
            int key; cin >> key;
            if (i == 0) tree = new_node(key);
            else insert(tree, key);
        } else if (query == "find") {
            int key; cin >> key;
            bool found = find(tree, key);
            cout << (found ? "yes" :  "no") << endl;
        } else {
            inorder(tree);
            cout << endl;
            preorder(tree);
            cout << endl;
        }
    }
}



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

vector<int> level(100001),comp(100001);

inline int getComp(int i){
  if(comp[i] != i) comp[i] = getComp(comp[i]);
  return comp[i];
}

inline void merge(int a,int b){
  a = getComp(a);
  b = getComp(b);
  if(level[a] > level[b]) swap(a,b);
  else if(level[a] == level[b]) ++level[b];
  comp[a] = b;
}

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,m,x,y,z;
  cin >> n >> m;
  iota(begin(comp),end(comp),0);
  while(m--){
    cin >> x >> y >> z;
    merge(x,y);
  }
  unordered_set<int> st;
  for(int i = 1; i <= n; ++i) st.insert(getComp(i));
  cout << st.size();
  return 0;
}

Measured memory_bytes: 5156
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    char C;
    string inp;
    cin>> N >> inp;
    for(int i=0; i<inp.length(); i++){
        C='A'+(inp.at(i)-'A'+N)%26;
        cout << C;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{ 
  for(;;){
    int houkosu={0};
	int comkosu={0};
	int hou[21][21]={{0},{0}};
	int zahyo[21][21]={{0},{0}};
	int mypox={10};
	int mypoy={10};
	int x={0},y={0};
	int i={0},j={0};
	char dire={0};
	int dis={0};
	int hantei={0};
	char dir[31]={0};
	int di[31]={0};
	
	scanf("%d",&houkosu);
	if(houkosu==0)
	  break;
	  
	for(i=0;i<houkosu;i++){
	  scanf("%d %d",&x,&y);
	  hou[x][y]=1;
	}

	scanf("%d",&comkosu);
	
	hou[10][10]=0;
	for(i=0;i<2*comkosu;i++){
      scanf("%c",&dire);
	  dir[i/2]=dire;
      scanf("%d",&dis);
      di[(i-1)/2]=dis;
	}
	
	for(i=0;i<comkosu;i++){

	  if(dir[i]=='N'){
	    for(j=mypoy+1;j<=mypoy+di[i];j++){
		  if(hou[mypox][j]==1)
		    hou[mypox][j]=0;
	    }
        mypoy+=di[i];
	  }else if(dir[i]=='S'){
	  	for(j=mypoy-1;j>=mypoy-di[i];j--){
		  if(hou[mypox][j]==1)
		    hou[mypox][j]=0;
	    }
        mypoy-=di[i];
	  }else if(dir[i]=='E'){
	    for(j=mypox+1;j<=mypox+di[i];j++){
		  if(hou[j][mypoy]==1)
		    hou[j][mypoy]=0;
	    }
        mypox+=di[i];
	  }else{
	    for(j=mypox-1;j>=mypox-di[i];j--){
		  if(hou[j][mypoy]==1)
		    hou[j][mypoy]=0;
	    }
        mypox-=di[i];
	  }
	}
	
	for(i=0;i<21;i++){
	  for(j=0;j<21;j++){
	    if(hou[i][j]!=0)
		  hantei=1;
	  }
	}
	
	if(hantei==0)
	  puts("Yes");
	else
	  puts("No");
	
  }
  return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>

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

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


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

    vector<pair<ll, int> > p(n);
    rep(i, n) p[i] = make_pair(a[i], i);

    sort(p.begin(), p.end());

    vector<ll> ans(n, 0);

    int i = n-1;
    while (i >= 0) {
        int j = i-1;
        while (p[j].second > p[i].second && j >= 0) {
            j--;
        }
        if (j < 0) {
            for (int k = j+1; k < i; k++) {
                ans[p[i].second] += p[k].first;
            }
            ans[p[i].second] += p[i].first * (n-i);
        } else {
            for (int k = j+1; k < i; k++) {
                ans[p[i].second] += p[k].first - p[j].first;
            }
            ans[p[i].second] += (p[i].first - p[j].first) * (n-i);
        }
        i = j;
    }

    rep(i, n) cout << ans[i] << endl;
    

    return 0;

}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

int popcount(int a) {
  int ret = 0;
  rep(i, 10) if (a & (1<<i)) ++ret;
  return ret;
}

int main() {
  int h, w, K; cin>>h>>w>>K;
  vector<string> s(h);
  rep(i, h) cin>>s[i];
  int ans = (h-1)+(w-1);

  rep(i, (1<<(h-1))) {
    int curans = popcount(i);
    vector<int> tmp(10, 0);
    bool good = true;
    rep(j, w) {
      int pos = 0;
      bool recalc = false;
      rep(k, h) {
        tmp[pos] += s[k][j] == '1';
        if (tmp[pos] > K) {
          recalc = true;
          ++curans;
          break;
        }
        if (k != h-1 and (i & (1<<k))) ++pos;
      }
      if (recalc) {
        pos = 0;
        rep(k, 10) tmp[k] = 0;
        rep(k, h) {
          tmp[pos] += s[k][j] == '1';
          if (tmp[pos] > K) good = false;
          if (k != h-1 and (i & (1<<k))) ++pos;
        }
      }
    }
    if (good) ans = min(ans, curans);
  }
  print(ans);

  return 0;
}

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

string s;
ll sum1 = 0, sum2;

int main()
{
    getline(cin, s);
    for(ll i = 0; i < s.size(); i++) sum1 += (int(s[i]) - (int)'0');
    sum2 = (int)s[0] - (int)'0' - 1 + 9 * (s.size() - 1);
    cout << max(sum1, sum2);
}


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;

/**
 * Library
 * --------------------------------------------------------
 */

/**
 * ワーシャルフロイド法
 * 隣接行列で受け取り、全頂点間最短経路を算出
 */
void warshall_floyd(Graph &graph) {
    int V = graph.size();
    for (int k = 0; k < V; ++k) {
        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < V; ++j) {
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }
}
/**
 * --------------------------------------------------------
 */

/**
 * https://atcoder.jp/contests/abc073/submissions/7665203
 * ABC 073 D - joisino's travel
 */
void Main() {
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r_list(R);
    rep(i, R) cin >> r_list[i];

    Graph graph(N, vector<ll>(N, INF));
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        graph[a][b] = c;
        graph[b][a] = c;
    }
    warshall_floyd(graph);

    sort(r_list.begin(), r_list.end());

    ll ans = INF;
    do {
        int start = r_list[0] - 1;
        ll tmp = 0;
        rep2(i, 1, R) {
            tmp += graph[start][r_list[i] - 1];
            start = r_list[i] - 1;
        }
        ans = min(ans, tmp);
    } while ((next_permutation(r_list.begin(), r_list.end())));
    cout << ans << '\n';
}

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


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

int main() {
	int N;
	int x = 0, ans = 0;
	string S;
	cin >> N >> S;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'I') x++; else x--;
		ans = max(ans, x);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
<?php
  $c[] = explode(" ",trim(fgets(STDIN)));
  $c[] = explode(" ",trim(fgets(STDIN)));
  $c[] = explode(" ",trim(fgets(STDIN)));
 
  for($i=0; $i<3; $i++){
      if($i==0){
          $p = $c[$i][$i];
          for($j=1; $j<3; $j++){
              $w[$j] = $c[$i][$j]-$p;
              $h[$j] = $c[$j][$i]-$p;
          }
          continue;
      }
    //   foreach($w as $j => $s){
    //       if($s != $c[$i][$j]-$c[$i][0]){
    //           echo "No";
    //           exit;
    //       }
    //   }
      foreach($h as $j => $s){
          if($s != $c[$j][$i]-$c[0][$i]){
              echo "No";
              exit;
          }
      }
  }
  echo "Yes";

Measured memory_bytes: 4604
#include<stdio.h>
char i;
int a[5], k;
int main(void){
  scanf("%d%d%d%d%d%d", a, a+1, a+2, a+3, a+4, &k);
  if(a[4]>a[0]+k){
    puts(":(");
  }else{
    puts("Yay!");
  }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

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

  int ans = dup(n-1, k-1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1020
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n;
  cin >> n;
  VI a(n);
  vector<PII> v(n);
  REP(i, n) cin >> a[i], v[i] = {a[i], i};

  sort(ALL(v));
  // cout << v << endl;
  int x = v[n/2-1].first, y = v[n/2].first;
  // cout << x << " " << y << endl;
  VI ans(n);
  REP(i, n) {
    if(i < n/2) {
      ans[v[i].second] = y;
    } else {
      ans[v[i].second] = x;
    }
  }

  REP(i, n) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 8448
//CODEFESTIVAL2016 C A
#include<iostream>
#include<string>

using namespace std;

int main()
{
	string s;
	cin >> s;
	bool isC = false;

	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'C')
			isC = true;
		else if (isC && s[i] == 'F')
		{
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
	return 0;

}

Measured memory_bytes: 256
main :: IO()
main = do
    ls <- map read . words <$> getLine
    k <- readLn
    print $ getsolve ls k
    
getsolve :: [Int] -> Int -> Int
getsolve ls k = withoutsum + ( maxnum * (2 ^ k))
                    where maxnum = maximum ls
                          withoutsum = sum ls - maxnum

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

int main(){
  string s,t;
  vector<string> v;
  cin>>s>>t;
  if(t.size()>s.size()){
    cout<<"UNRESTORABLE"<<endl;
    return 0;
  }

  for(int i=0;i<=s.size()-t.size();i++){
    string u=s;
    for(int a=0;a<u.size();a++){
      if(u[a]=='?')u[a]='a';
    }
    for(int j=0;j<t.size();j++){
      u[i+j]=t[j];
    }
    v.push_back(u);
  }
  sort(v.begin(),v.end());

  for(int i=0;i<v.size();i++){
    bool jdg=true;
    for(int j=0;j<v[i].size();j++){
      if(s[j]!='?'&& s[j]!=v[i][j]){
        jdg=false;
      }
    }
    if(jdg){
      cout<<v[i]<<endl;
      return 0;
    }
  }
  cout<<"UNRESTORABLE"<<endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    string S;
    cin >> S;
    int N = S.size();
    REP(i,N){
        printf("%c", 'x');
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
vector<ll> v;
vector<bool> ans;

int main()
{
	ll n, i, j, a, b, k, cnt=0;
	cin >> n >> k;
	v.resize(n+1);

	for(i=1; i<=n; i++)
		cin >> v[i];
	
	for(i=k+1; i<=n; i++){
		if (v[i] > v[i-k])
			ans.push_back(true);
		else
			ans.push_back(false);
	}
	
	for(i=0; i<ans.size(); i++){
		if (ans[i] == false)
			cout << "No" << endl;
		else
			cout << "Yes" << endl;
	}

	return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

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

typedef long double ld;
const ld eps = 1.0e-10; // 許容される誤差

ld mysqrtl(ld x)
{
  ld a = sqrt((double)x); // 近似値
  do {
    a = (a + x/a) / 2.0L;
  } while (fabsl(x - a*a) > eps);
  return a;
}

int main(){
	#define int ll
	cin.tie(0);
	ios::sync_with_stdio(false);
	// ここに処理を記述

	long double a, b, c;
	cin >> a >> b >> c;

	if(4*a*b < (c-a-b)*(c-a-b) && (c-a-b) >= 0) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}

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

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

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

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

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

typedef tuple<int,int,int> parsed;

parsed expr(const string& s,int i,vector<parsed>& memo);

parsed fact(const string& s,int i,vector<parsed>& memo)
{
	if(memo[i]!=parsed(-1,-1,-1)) return memo[i];
	auto& res=memo[i];
	int t,f;
	if(s[i]=='~'){
		tie(t,f,i)=fact(s,i+1,memo);
		swap(t,f);
	}
	else if(s[i]=='('){
		tie(t,f,i)=expr(s,i+1,memo);
		i++;
	}
	else{
		for(i++;i<s.size() && isdigit(s[i]);i++)
			;
		t=f=1;
	}
	return res=parsed(t,f,i);
}

parsed term(const string& s,int i,vector<parsed>& memo)
{
	//if(memo[i]!=parsed(-1,-1,-1)) return memo[i];
	auto& res=memo[i];
	int t,f; tie(t,f,i)=fact(s,i,memo);
	while(i<s.size() && s[i]=='&'){
		int t2,f2; tie(t2,f2,i)=fact(s,i+1,memo);
		ll sum=ll(t+f)*ll(t2+f2);
		tie(t,f)=mp(ll(t)*t2%MOD,(sum-ll(t)*t2)%MOD);
	}
	return res=parsed(t,f,i);
}

parsed expr(const string& s,int i,vector<parsed>& memo)
{
	//if(memo[i]!=parsed(-1,-1,-1)) return memo[i];
	auto& res=memo[i];
	int t,f; tie(t,f,i)=term(s,i,memo);
	while(i<s.size() && s[i]=='|'){
		int t2,f2; tie(t2,f2,i)=term(s,i+1,memo);
		ll sum=ll(t+f)*ll(t2+f2);
		tie(t,f)=mp((sum-ll(f)*f2)%MOD,ll(f)*f2%MOD);
	}
	return res=parsed(t,f,i);
}

int main()
{
	for(string s;getline(cin,s) && s!="#";){
		vector<parsed> memo(s.size(),parsed(-1,-1,-1));
		per(i,s.size()) if(s[i]=='(') fact(s,i,memo);
		int t,f,i; tie(t,f,i)=expr(s,0,memo);
		cout<<t<<endl;
	}
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int x, y;
    cin >> x >> y;
    for (int i = 0; i <= x; ++i) {
        if (2 * i  + 4 * (x - i) == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int digit(ll num){//桁数
    return log10(num)+1;
}

int main() {
    ll n; cin >> n;
    // ll ans = 0;
    // cout << digit(4109) << endl;
    ll num = 1;
    while(1){
        if(n - pow(26, num) < 0) break;
        n -= pow(26, num);
        if(n == 0){
            rep(i, num){
                cout << "z";
            }
            cout << endl;
            return 0;
        }
        num++;
    }
    num--;
    // cout << "num = " << num << endl;
    // cout << "n = " << n << endl;

    for(int i = num; i >= 0; i--){
        char moji = 'a';
        int a = 1;
        // cout << "dd" << endl;
        while(1){
            if(n - pow(26, i)*a <= 0){
                n -= pow(26, i)*(a-1);
                // cout << "n = " << n << endl;
                // cout << "a = " << a << endl;
                printf("%c", moji + a - 1);
                // cout << moji + a - 1;
                // cout << "aa" << endl;
                break;
            }
            a++;
            // cout << "cc" << endl;
        }

    }
    cout << endl;

    // cout << num << endl;


    return 0;
}

Measured memory_bytes: 4024
//*******Abhijit Burman***********//
//Jalpaiguri Government Engineering College//

// Taken From Striver_79
// Never open a ranklist untill and unless you are done with solving problems, wastes 3/4 minuts 
// Donot treat CP as a placement thing, love it and enjoy it, you will succeed for sure. 


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define MAXX (1000000000000000000+7)
#define mod 1000000007
#define endl "\n"
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
void input(ll a[], ll sz) {for(ll i=0;i<sz;i++) cin >> a[i];}
void print(ll a[], ll sz) {for(ll i=0;i<sz;i++) {if (i == sz - 1) cout << a[i] << "\n"; else cout << a[i] << " ";}}
ll dx1[] = {1, 1, 0, -1, -1, -1, 0, 1};
ll dy1[] = {0, 1, 1, 1, 0, -1, -1, -1};

ll dx2[] = {1, 0, -1, 0};
ll dy2[] = {0, 1, 0, -1};

ll mul(ll a, ll b, ll p = mod) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = mod) {return (a % p + b % p) % p;}
ll power(ll x,ll y,ll p = mod) 
{ 
    ll res = 1;
    x = x % p;
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % p;
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n, ll p = mod)
{
    return power(n, p - 2, p);
}
ll ncrMod(ll n, ll r, ll p = mod)
{
    if (r == 0)
        return 1;
    ll fac[n + 1];
    fac[0] = 1;
    for (ll i = 1 ; i <= n; i++)
        fac[i] = fac[i - 1] * i % p;
    return (fac[n] * modInverse(fac[r], p) % p *
            modInverse(fac[n - r], p) % p) % p;
}
// a+b=xor(a,b)+2*(a&b)//

bool isPrime(ll n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            return false;
        }
    }
    return true;
}


void solve()
{
    ll a,b,c;
    cin>>a>>b>>c;
    ll cnt=0;
    while(a>0){
        a-=b;
        cnt+=c;
    }
    cout<<cnt<<endl;
}


int main()
{
	fio;
// 	#ifndef ONLINE_JUDGE
//     // for getting input from input.txt
//     freopen("input.txt", "r", stdin);
//     // for writing output to output.txt
//     freopen("output.txt", "w", stdout);
// 	#endif
 

	ll t=1;
// 	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

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

int main()
{
	int n; cin >> n;
	string s; cin >> s;
	
	int tmp_x = 0;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'I') tmp_x++;
		else tmp_x--;
		ans = max(ans, tmp_x);
	}

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n, m, a[100009]; long long sum[100009], psum[100009];
int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i - 1];
	for (int i = 1; i <= n; i++) psum[i] = psum[i - 1] + max(a[i - 1], 0);
	long long ret = 0;
	for (int i = 0; i <= n - m; i++) {
		long long suml = psum[i] - psum[0];
		long long sumr = psum[n] - psum[i + m];
		long long summ = max(sum[i + m] - sum[i], 0LL);
		ret = max(ret, suml + sumr + summ);
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 2176
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
	  	Scanner scanner = new Scanner(System.in);
	  	int  n = scanner.nextInt();	
	  	boolean j = true;
	  
	  	
	  	for(int i = 1 ; i <= n ; i ++) {
			if(i %10 == 3 || i % 3 == 0 ) {
				System.out.print(" " + i);
				j = false;
			}
			if( j && i % 100 > 29 && i % 100 <  40) {
				System.out.print(" " + i);
				j = false;
			}
			if( j && i % 1000 > 299 && i % 1000 <  400) {
				System.out.print(" " + i);
				j = false;
			}
			if( j && i % 10000 > 2999 && i % 10000 <  4000) {
				System.out.print(" " + i);
				j = false;
			}
			
			if(!j)
				j = true;
			
	  	}
		System.out.print("\n");
        scanner.close();
	}
}


Measured memory_bytes: 28520
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <cstring>
#include <stack>
#include <cstdio>
#include <complex>
#include <iomanip>
#include <cstring>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define show(x) cout << #x << " = " << x << endl;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(b-a==c-b)puts("YES");
    else puts("NO");
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string.h>

int main()
{
    unsigned long long int a;
    std::string s = "";
    std::cin >> a;
  
    while(true){
      char b = 'a' + ((a - 1) % 26);
      s += b;
      a = (a - 1) / 26;
      if (a <= 0) break;
    }
  
    std::reverse(s.begin(), s.end());
    std::cout << s << std::endl;
}

Measured memory_bytes: 3624
/**
*	  Name: Ajay Subhash Jadhav
*	  Institute: International Institute of Technology Hyderabad 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void inputread()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}

int main(){
      
  fastio();
  
  int n,m,i,j,t;
  cin>>n;
  vi a(n);
  int sum=0;
  for(i=0;i<n;i++)
  {
  	cin>>a[i];
  	a[i]-=(i+1);
  }
  sort(a.begin(),a.end());
  int median=n/2+n%2-1;
  int medians=a[median];
  LL ans=0;

  for(i=0;i<n;i++)
  {
  	ans+=abs(a[i]-(medians));
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
		else {
			break;
		}
	}
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination1(int, int);
};
int Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_Password(void) {

	int N; cin >> N;
	cout << N * N * N << flush;
	return;
}

int main(void) {

	A_Password();
	return 0;
}


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

int main()
{
    int n, m, x, in;
    cin >> n >> m >> x;
    int a[150];
    for(int i = 0; i <= 140; i++){
        a[i] = 0;
    }
    for(int i = 1; i <= m; i++){
        cin >> in;
        a[in] = 1;
    }
    int cost = 0;
    for(int i = 0; i <= x; i++){
        cost = cost + a[i];
    }
    if(cost > m - cost){
        cost = m - cost;
    }
    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 256
n,l = map(int,input().split())
if l>0:
    print(n*l-n-l+n*(n+1)//2)
elif l+n>0:
    c = 0
    for i in range(1,n+1):
        c += l+i-1
    print(c)
else:
    print(l*n-n-(l+n-1)+n*(n+1)//2)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MN = 1e5+100;
ll t[MN];
ll add[MN];
ll ans[MN];
int main() {
    ll n,q;
    cin>>n>>q;
    vector<ll> v;
    v.push_back(n);
    for(int i = 0; i < q; ++i) {
        ll x;
        cin>>x;
        while(v.size() && v.back() >= x) {
            v.pop_back();
        }
        v.push_back(x);
    }

    t[(int)v.size()-1] = 1;
    for(int i = (int)v.size()-1; i >= 0; --i) {
        if(i == 0) {
            add[v[0]] += t[0];
            break;
        }
        ll sz = v[i] - v[i-1];
        t[i-1] += t[i];
        while(sz) {
            int lo = 0;
            int hi = i-1;
            int best = 0;
            while(lo <= hi) {
                int mid = (lo+hi)/2;
                if(v[mid] <= sz) {
                    best = mid;
                    lo = mid+1;
                }
                else {
                    hi = mid-1;
                }
            }
            //cout<<best<<' '<<sz<<'\n';
            if(best == 0) {
                add[v[0]] += sz/v[0]*t[i];
                add[sz%v[0]] += t[i];
                sz = 0;
            }
            else {
                t[best] += sz/v[best]*t[i];
                sz %= v[best];
            }
        }
    }
    ll sum = 0;
    for(int i = n; i > 0; --i) {
        sum += add[i];
        ans[i] = sum;
    }
    for(int i = 1; i <= n; ++i) {
        cout<<ans[i]<<'\n';
    }
}


Measured memory_bytes: 4980
#include <iostream>

using namespace std;

int main(){
    int a;
    int b;
    cin >> a >> b;
    double f; 
    f = 1.00000 * a / b;
    cout << a / b << " ";
    cout << a % b << " ";
    cout.setf(std::ios_base::fixed,std::ios_base::floatfield);
    cout << f << endl;
}


Measured memory_bytes: 3248
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(){
	int x,y;
	scanf("%d %d",&x,&y);
	printf("%d\n",x + (y/2));
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>v_0(100000,0);
    vector<int>v_1(100000,0);
    int v;
    for(int i=0;i<n;i++){
        cin>>v;
        switch(i%2){
            case 0:
            v_0[v]++;
            break;
            case 1:
            v_1[v]++;
            break;
        }
    }
    if(max_element(v_0.begin(),v_0.end())-v_0.begin()==max_element(v_1.begin(),v_1.end())-v_1.begin()){
        sort(v_0.begin(),v_0.end(),greater<int>());
        sort(v_1.begin(),v_1.end(),greater<int>());
        cout<<n-max({v_0[0]+v_1[1],v_0[1]+v_1[0]})<<endl;
        exit(0);
    }
    cout<<n-*max_element(v_0.begin(),v_0.end())-*max_element(v_1.begin(),v_1.end())<<endl;
}

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


del_flag = [0 for i in range(n)]
value = 1
for i in range(n):
    if a[i] == value:
        value += 1
        continue
    del_flag[i] = 1

ans = sum(del_flag)
if ans == n:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 26268
#include <queue>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
struct state {
	int pos, cost;
};
bool operator<(const state& s1, const state& s2) {
	return s1.cost < s2.cost;
}
int n, p[109], dist[109]; string s[109];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		s[i] = "";
		while (s[i] == "") getline(cin, s[i]);
	}
	fill(p, p + n, -1);
	for (int i = 0; i < n; i++) {
		if (s[i].size() >= 5 && s[i].substr(0, 5) == "goto ") {
			string t = s[i].substr(5, s[i].size() - 6);
			for (int j = 0; j < n; j++) {
				if (s[j] == t + ":") p[i] = j;
			}
		}
	}
	fill(dist, dist + n + 1, 999999999); dist[0] = 0;
	priority_queue<state> que; que.push(state{ 0, 0 });
	while (!que.empty()) {
		state u = que.top(); que.pop();
		if (u.pos == n) continue;
		if (p[u.pos] != -1) {
			if (dist[p[u.pos]] > dist[u.pos]) {
				dist[p[u.pos]] = dist[u.pos];
				que.push(state{ p[u.pos], -dist[p[u.pos]] });
			}
		}
		int cost = dist[u.pos] + (p[u.pos] == -1 ? 0 : 1);
		if (dist[u.pos + 1] > cost) {
			dist[u.pos + 1] = cost;
			que.push(state{ u.pos + 1, -cost });
		}
	}
	cout << dist[n] << endl;
	return 0;
}

Measured memory_bytes: 3148
use std::io;


/// https://beta.atcoder.jp/contests/arc089/tasks/arc089_a
fn main() {
    let n = read_one::<usize>();
    let mut txy = Vec::new();
    for _ in 0..n {
        let i = read::<isize>();
        txy.push((i[0], i[1], i[2]));
    }

    txy.sort_by_key(|&(t, _, _)| -t);
    let mut prev_x = 0;
    let mut prev_y = 0;
    let mut prev_t = 0;
    let mut flg = true;

    while let Some((t, x, y)) = txy.pop() {
        let d = (x - prev_x).abs() + (y - prev_y).abs();
        if d > (t - prev_t) { flg = false; }
        if (t - prev_t) % 2 != d % 2 { flg = false; }
        prev_x = x;
        prev_y = y;
        prev_t = t;
    }

    if flg { println!("Yes"); }
    else { println!("No"); }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 9336
//#typedef int ll
// include
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <tuple>
// namespace
using namespace std;
// typedef
typedef long long ll;
typedef long double ld;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pint;
// const
const int inf = 1e9;
const ll mod = ((ll)1e9 + 7);
// loop
#define rep(i, n) for(int i = 0, i##_mx = n; i < i##_mx; i++)
#define brep(i, b, e) for(int i = b; i < e; i++)
#define erep(i, b, e) for(int i = b; i <= e; i++)
#define rrep(i, b, e) for(int i = b; i >= e; i--)
// STL
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(), (v).end()
// sort
#define vsort(v, b) sort(all(v), [](auto l, auto r){return (b);})
// access
#define gt(i, n) get<n>(i)
// function
ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
void prime(vint& v, int n){brep(i, 2, n){bool fg = false; for(auto e : v){if(i % e == 0){fg = true;}} if(fg){continue;} v.pb(i);}}
void in(vint& v){for(auto& i : v){cin >> i;}}
void in(vll& v){for(auto& i : v){cin >> i;}}
ll egcd(ll a, ll b, ll& x, ll& y){if(b == 0){x = 1; y = 0; return a;} ll d = egcd(b, a % b, y, x); y -= a / b * x; return d;}

signed main(){
    ll n, k;
    cin >> n >> k;
    
    ll ans = 0;
    ll blue = 1, red = n - k + 1;
    
    ll x, y;
    erep(i, 1, k){
        cout << (blue * red) % mod << endl;
        
        blue *= k - i;
        blue %= mod;
        egcd(i, mod, x, y);
        while(x < 0){
            x += mod;
        }
        blue *= x;
        blue %= mod;
        
        red *= n - k - i + 1;
        red %= mod;
        egcd(i + 1, mod, x, y);
        while(x < 0){
            x += mod;
        }
        red *= x;
        red %= mod;
    }
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<limits>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int n,m,nue,mue;
	cin>>n>>m;
	nue=n*(n-1);
	mue=m*(m-1);
	//cout<<n<<","<<m<<endl;
	cout<<nue/2+mue/2<<endl;
}

Measured memory_bytes: 256
def gcd(a,b):
    return gcd(b, a%b) if b else a
N = int(input())
a = list(map(int,input().split()))
gcdl = [a[0]]
gcdr = [a[N-1]]
for i in range(1,N-1):
    gcdl.append(gcd(gcdl[i-1],a[i]))
    gcdr.append(gcd(gcdr[i-1],a[N-i-1]))
import numpy as np
ans = np.maximum(gcdl[N-2],gcdr[N-2])
gcdl.pop()
gcdr.pop()
gcdr.sort()
for i in range(N-2):
    if ans < gcd(gcdl[i],gcdr[i]):
        ans = gcd(gcdl[i],gcdr[i])
print(ans)

Measured memory_bytes: 18504
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

A, B = nm()

print(A * B - A - B + 1)

Measured memory_bytes: 3696
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define ll long long
const int MOD=1e9+7;
ll ans;
int n;
char a[60],b[60];
void dfs(int cnt,int flag,ll sum)
{
    if(cnt==n)
    {
        ans=(ans+sum)%MOD;
        return ;
    }
    if(cnt+1<n&&a[cnt]==a[cnt+1]&&b[cnt]==b[cnt+1])
    {
        if(!flag)
            dfs(cnt+2,2,sum*6%MOD);
        else if(flag==1)
            dfs(cnt+2,2,sum*2%MOD);
        else
            dfs(cnt+2,2,sum*3%MOD);
    }
    if(a[cnt]==b[cnt])
    {
        if(!flag)
            dfs(cnt+1,1,sum*3%MOD);
        else if(flag==1)
            dfs(cnt+1,1,sum*2%MOD);
        else
            dfs(cnt+1,1,sum%MOD);
    }
}
int main()
{
    scanf("%d%s%s",&n,a,b);
    dfs(0,0,1);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
import sys
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row_list(N): return [i_list() for _ in range(N)]
sys.setrecursionlimit(10 ** 6)
INF = float('inf')

def main():
    d = i_input()
    c_list = i_list()
    s_list = i_row_list(d)

    last_list = [0] * 26

    for day in range(1,d+1):
        result = 0
        max_point = -INF
        for i in range(26):
            plus_point = s_list[day-1][i]
            minus_point = 0
            for j in range(26):
                if i == j:
                    continue
                minus_point += c_list[j] * (day - last_list[j])
            sum_point = plus_point - minus_point
            if sum_point > max_point:
                result = i + 1
                max_point = sum_point
        print(result)
        last_list[result-1] = day

if __name__ == '__main__':
    main()


Measured memory_bytes: 68976
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
ll gcd(ll a, ll b){
  if(b==0) return a;
  else gcd(b,a%b);
}
ll lcm(ll a, ll b){
  return a/gcd(a,b)*b;
}

int main(){
  int n,m;
  cin >> n >> m;
  vector<int>vec(n);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;
    b--;
    vec[a]++;
    vec[b]++;
  }
  int ans=0;
  rep(i,n)if(vec[i]%2!=0)ans++;
  if(ans)cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String args[])throws Exception{
    BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
    int N = Integer.parseInt(br.readLine());
    String s = br.readLine();
    int R=0;
    int W=0;
    for(int i=0; i<N; i++){
        if(s.charAt(i)=='R') R++;
        else W++;
    }
    int ans = 0;
    for(int i=0; i<R; i++) if(s.charAt(i)=='W') ans++;
    System.out.println(ans);
}
}

Measured memory_bytes: 35956
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    h, w, n = LI()
    sr, sc = LI_()
    S = SI()
    T = SI()

    D = {0: ('L', 'R', -1), 1: ('R', 'L', 1), 2: ('U', 'D', -1), 3: ('D', 'U', 1)}
    is_drop = False
    for t in range(2):
        taka, aoki, d = D[t]
        x = sc
        for i in range(n):
            if S[i] == taka:
                x += d
                if x < 0 or x >= w:
                    is_drop = True
                    break
            if T[i] == aoki:
                x -= d
                if x < 0:
                    x = 0
                if x >= w:
                    x = w - 1

    for t in range(2, 4):
        taka, aoki, d = D[t]
        y = sr
        for i in range(n):
            if S[i] == taka:
                y += d
                if y < 0 or y >= h:
                    is_drop = True
                    break
            if T[i] == aoki:
                y -= d
                if y < 0:
                    y = 0
                if y >= h:
                    y = h - 1

    print('NO' if is_drop else 'YES')



if __name__ == '__main__':
    main()

Measured memory_bytes: 42464
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	int N, M; cin >> N >> M;
	int a[51], b[51];
	int C[51];
	rep(i, 0, N + 1) {
		C[i] = 0;
	}

	rep(i, 0, M) {
		cin >> a[i] >> b[i];
		C[a[i]]++;
		C[b[i]]++;
	}

	rep(i, 1, N + 1) {
		cout << C[i] << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int r,c,A[101][101] = {0};
	int i, j;
	scanf("%d %d", &r, &c);
	for (i=0; i < r; i++)
	{
		for (j=0; j < c; j++)
		{
			scanf("%d", &A[i][j]);
			A[r][j] = A[r][j] + A[i][j];
			A[i][c] = A[i][c] + A[i][j];
			A[r][c] = A[r][c] + A[i][j];
		}
	}
	
	for (i=0; i <= r; i++)
	{
		for (j = 0; j <=c; j++)
		{
			printf("%d", A[i][j]);
			if (j != c)
			{
				printf(" ");
			}
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 652
#include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>

using namespace std;

const double EPS=(1e-10);
typedef long long ll;
typedef pair<int,int> pii;
bool EQ(double a,double b){
  return abs((a)-(b))<EPS;
}
void fast_stream(){
  std::ios_base::sync_with_stdio(0);
}

int H,W,C,M,Nw,Nc,Nm;

const int MAX_V=3001;
const ll INF=1000000000000000LL;

class edge{
public:
  int to,rev;
  ll cap;
  edge(int to_,ll cap_,int rev_){
    to=to_;
    cap=cap_;
    rev=rev_;
  }
};

vector<edge> G[MAX_V];
// sツつゥツづァツづ個仰猟猟」
int level[MAX_V];
// ツづつアツづ慊づ陳イツづ猟終ツづュツづつスツつゥ
int iter[MAX_V];
void add_edge(int from,int to,ll cap){
  G[from].push_back(edge(to,cap,G[to].size()));
  G[to].push_back(edge(from,0,G[from].size()-1));
}
// sツつゥツづァツづ個催短ツ仰猟猟」ツづーツ仰づ淞づゥ
void bfs(int s){
  memset(level,-1,sizeof(level));
  queue<int> que;
  level[s]=0;
  que.push(s);
  while(!que.empty()){
    int v=que.front();que.pop();
    for(int i=0;i<G[v].size();i++){
      edge &e=G[v][i];
      if(e.cap>0&&level[e.to]<0){
	level[e.to]=level[v]+1;
	que.push(e.to);
      }
    }
  }
}
// ツ堕敖嘉パツスツづーdfsツづ探ツつキ
ll dfs(int v,int t,ll f){
  if(v==t)return f;
  for(int &i=iter[v];i<G[v].size();i++){
    edge &e=G[v][i];
    if(e.cap>0&&level[v]<level[e.to]){
      ll d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
	e.cap-=d;
	G[e.to][e.rev].cap+=d;
	return d;
      }
    }
  }
  return 0;
}
// sツつゥツづァtツづ鳴づ個催妥・ツ猟ャツづーツ仰づ淞づゥ
ll max_flow(int s,int t){
  ll flow=0;
  while(1){
    bfs(s);
    if(level[t]<0)return flow;
    memset(iter,0,sizeof(iter));
    ll f;
    while((f=dfs(s,t,INF))>0)flow+=f;
  }
}

int main(){
  while(cin>>H>>W>>C>>M>>Nw>>Nc>>Nm
	&&!(H<0&&W<0&&C<0&&M<0&&Nw<0&&Nc<0&&Nm<0)){
    const int s=1999;
    const int g=2000;
    const int nwNum=1998;
    const int nwNum2=1995;
    const int ncNum=1997;
    const int ncNum2=1994;
    const int nmNum=1996;
    
    for(int i=0;i<MAX_V;i++)G[i].clear();
    // ツゴツーツδ仰づ鳴古シツつゥツつ、ツ陛環δ仰ーツト
    add_edge(nwNum,nwNum2,Nw);
    //add_edge(nwNum2,ncNum,100);
    add_edge(ncNum,ncNum2,Nc);
    //add_edge(ncNum2,nmNum,100);
    add_edge(nmNum,g,Nm);
    
    for(int i=0;i<H;i++){
      add_edge(s,i,1);
      add_edge(i,nwNum,1);
    }
    for(int i=0;i<W;i++){
      add_edge(H+i,H+W+i,1);
      add_edge(H+W+i,ncNum,1);
      int num;
      cin>>num;
      while(num--){
	int t;
	cin>>t;
	add_edge(t-1,H+i,1);
      }
    }
    for(int i=0;i<C;i++){
      add_edge(nwNum2,H+2*W+i,100);
      add_edge(H+2*W+i,H+2*W+C+i,1);
      add_edge(H+2*W+C+i,nmNum,1);
      int num;
      cin>>num;
      while(num--){
	int t;
	cin>>t;
	add_edge(t-1+H+W,H+2*W+i,1);
      }
    }
    for(int i=0;i<M;i++){
      add_edge(ncNum2,H+2*W+2*C+i,100);
      add_edge(H+2*W+2*C+i,g,1);
      int num;
      cin>>num;
      while(num--){
	int t;
	cin>>t;
	add_edge(t-1+H+2*W+C,H+2*W+2*C+i,1);
      }
    }
    ll res=max_flow(s,g);
    cout<<res<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#define lpa(i,a,b) for(int i=a; i<b; ++i)
#define lp(i,n) lpa(i,0,n)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define print_v(v,n) lp(i,n) cout<<v[i]<<' '; cout<<'\n';
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
ll md = 1e9+7;
int n, k;
std::vector<std::vector<int> > gr;
int main(int argc, char const *argv[])
{
	cin>>n>>k;
	gr.resize(n);
	lp(i, n-1){
		int x, y; cin>>x>>y; --x, --y;
		gr[x].pb(y);
		gr[y].pb(x);
	}
	queue<pair<int, int>> bf;
	ll ans = k;
	lp(i, gr[0].size()){
		ans = (ans * (k - i - 1)) % md;
		bf.push(mp(gr[0][i], 0));
	}
	while(!bf.empty()){
		int sz = bf.size();
		for(int i = 0; i < sz; ++i){
			pii tp = bf.front();
			bf.pop();
			int f = k - 2;
//			print_v(gr[tp.first], gr[tp.first].size());
			for(auto it: gr[tp.first]){
				if(it != tp.second){
					bf.push(mp(it, tp.first));
					ans = (ans * f)%md;
//					cout<<ans<<' '<<it<<' '<<f<<' '<<tp.first;
					--f;
				}
			}
//			cout<<endl;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6904