akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    int a, b;
    cin >> a >> b;
    for (int x = 0; x <= 1000000; x++)
    {
        if ((int)(x * 0.08) == a && (int)(x * 0.1) == b)
        {
            cout << x << endl;
            return;
        }
    }
    cout << -1 << endl;
}

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


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

long long GCD(long long a, long long b) {
    if(b == 0)
        return a;
    else
        return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
    long long g = GCD(a, b);
    return a / g * b;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long> H(N);
    rep(i, 0, N) { cin >> H[i]; }
    if(K >= N) {
        cout << 0 << endl;
    } else {
        long long res = 0;
        sort(H.begin(), H.end(), greater<int>());
        rep(i, 0, N) {
            if(i >= K) {
            //    cout << i << "," << H[i] << endl;
                res += H[i];
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 1792
/*..............................................*\
Author:Kishor Kumar Paroi
Dept:CSE-1703053
email.kishor.josephite@gmail.com
RUET,BANGLADESH
\*---------------------------*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <sstream>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include<bits/stdc++.h>
#include<iostream>
#include<iterator>

#define max(a,b) ((a>b)?a:b)                        //finding max
#define min(a,b) ((a<b)?a:b)                        //finding min
#define Max(a,b,c) max(a,max(b,c))                  //finding max between 3 numbers
#define Min(a,b,c) min(a,min(b,c))                  //finding min between 3 numbers
#define Pi acos(-1.0)                               //defining Pi for mathematical uses
#define Clear(a) memset(a,0,sizeof(a))              //clearing memory of an array
#define setfalse(a) memset(a,false,sizeof(a))       //setting the array into false
#define settrue(a) memset(a,true,sizeof(a))         //setting the array into true
#define clrstr(a) memset(a,'\0',sizeof(a))          //setting string array to null
#define open freopen("input.txt","r",stdin)         //opening input file
#define close freopen ("output.txt","w",stdout)     //opening output file
#define Case(a) printf("Case %d: ",a)               //printing case number
#define caseh(a) printf("Case #%d: ",a)             //printing case number having '#'
#define getcase(a) scanf("%d",&a)                   //scanning case number
#define caseloop(a,b) for(a=1;a<=b;a++)             //making case loop
#define EPS 1e-9                                    //small value for avoiding preccesion error
#define LL long long                                //long long short form
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vi vector<int>v
//const int N=100*1000;
//const int mod=1e9+7;

//# define int min3(int a,int b,int c){return min(a,min(b,c));}
//#define int max3(int a,int b,int c){return max(a,max(b,c));}
//#define int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
//#define int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  cout << (e-a-k>0?":(":"Yay!") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<chrono>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll,ll> P;
struct edge{ int to,cost; };
#define VMAX 100000

ll N,M,K;
ll A[100010],B,C,D,X,Y;
ll ans=0;
ll G[100010];
string S,T,U;
ll F[100010];
bool ok=true;
std::queue<ll> Q;
ll Z[]={1,2,3,6,7,8,9,0};

int main(){
    cin>>N;
    ll n,m,a;
    n=N;m=26;
    while(n>0){
        n--;
        S+='a'+n%26;
        n/=26;
        
    }
    reverse(ALL(S));
    cout<<S;
    
}


Measured memory_bytes: 3640
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
2
3 4
---+/
/+---test
3
500 300 200
---+/
/+---test
5
138 138 138 138 138
---+/

void main(string[] args) {
  readln;

  const V = readln.split.map!(to!long).array.sort!"a < b".array;

  double ans = V[0];
  foreach (i; 1..V.length) {
    ans = (ans + V[i])/2;
  }
  "%.10f".writefln(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<tr1::unordered_map>
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,a,n) for(int i=n;i>=a;--i)
#define pb push_back
#define fi first
#define se second
#define io std::ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
const int  maxn=1e6+50;
ll gcd(ll a,ll b)
{
    return b?gcd(b,a%b):a;
}
ll qpow(ll a,ll n)
{
    ll r=1%P;
    for (a%=P; n; a=a*a%P,n>>=1)if(n&1)r=r*a%P;
    return r;
}
struct node
{
  int a[26];
  int b[26];
};
node tree[maxn];
int pre[maxn];
int cnt;
int ans;
void add(string x)
{ int cur=0;
  int flag=0;
  for(int i=0;i<x.size();i++)
  { 
      int now=x[i]-'a';
      if(!tree[cur].a[now]) {
        tree[cur].a[now]=++cnt;
        pre[cnt]=cur;
      }
      cur=tree[cur].a[now];
  }
  int len=x.size()-1;
  int cntt[26];
  memset(cntt,0,sizeof(cntt));
  while(cur)
  {
        int pe=pre[cur];
        int now=x[len]-'a';
          if(!cntt[now])
          {
            cntt[now]++;
          }
        for(int i=0;i<26;i++)
        {
          if(cntt[i])
            tree[pe].b[i]++;
        }
        cur=pre[cur];
        len--;
  }
}
string a[maxn];
bool cmp(string x,string y)
{
  return x.size()>y.size();
}
int main()
{ io;
  int n;
  cin>>n;
  for(int i=1;i<=n;i++)
  {
    cin>>a[i];
  }
  sort(a+1,a+1+n,cmp);
  for(int i=1;i<=n;i++)
  {
    reverse(a[i].begin(),a[i].end());
    int cur=0;
    int flag=0;
    for(int j=0;j<a[i].size()-1;j++)
      {
        char x=a[i][j];
        int now=x-'a';
        if(!tree[cur].a[now]) {flag=1;break;}
        cur=tree[cur].a[now];
      }
    if(flag) { add(a[i]);continue;}
    int last=a[i].back()-'a';
    ans+=tree[cur].b[last];
    add(a[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 242612
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

const ll MOD = 1e9 + 7;

int main() {
#ifdef DEBUG
  ifstream cin("in.txt");
#endif
  int N;
  string S;
  while (cin >> N >> S) {
    vector<int> cnt(26, 0);
    for (char c : S) ++cnt[c - 'a'];
    ll res = 1;
    for (int x : cnt) res = res * (x + 1) % MOD;
    res = (res - 1 + MOD) % MOD;
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>

using namespace std;

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); }

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<int> l(n + 1, 0), r(n + 1, 0);

	for (int i = 0; i < n; i++) {
		l[i + 1] = gcd(l[i], a[i]);
	}
	for (int i = n - 1; i >= 0; i--) {
		r[i] = gcd(r[i + 1], a[i]);
	}

	int res = 0;
	for (int i = 0; i < n; i++) {
		int left = l[i];
		int right = r[i + 1];
		chmax(res, gcd(left, right));
	}
	cout << res << endl;
}

Measured memory_bytes: 1408
#!/usr/bin/env ruby
# frozen_string_literal: true
n,l= gets.split.map(&:to_i)
sum = 0
arr = []
n.times do |i|
  arr << l+i
  sum += l+i
end
sa = sum if l <= 0 && n-1+l > 0
sa = sum - arr[-1] if l < 0 && n-1+l <= 0
sa = sum -arr[0] if l >= 0
puts sa

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

int main(void){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    rep(ki, k){
        vector<int> b(n + 1);
        rep(i, n){
            int l = max(0, i - a[i]), r = min(n, i + a[i] + 1);
            b[l]++; b[r]--;
        }
        rep(i, n) b[i + 1] += b[i];
        b.pop_back();
        if(a == b) break;
        a = b;
    }
    rep(i, n) cout << a[i] << endl;
    return 0;
}

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

int main(void){
  int h,w;
  std::string a[100];
  
  std::cin >> h >> w;
  for(int i=0;i<h;i++){
    std::cin >> a[i];
  }
  for(int i=0;i<w+2;i++){
    std::cout << "#";
  }
  std::cout << std::endl;
  for(int i=0;i<h;i++){
    std::cout << "#";
    std::cout << a[i];
    std::cout << "#" <<std::endl;
  }
  for(int i=0;i<w+2;i++){
    std::cout << "#";
  }
  std::cout << std::endl;
}

  

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long 
int main(){
  ll f[100001]={0};
  ll n;
  cin>>n;
  for(ll i=0; i<n; i++){
  	ll temp; cin>>temp;
  	f[temp]++;
  }
  ll sum = 0;
  for(ll i=0; i<100001; i++){
  	sum+=(i*f[i]);
  }
  ll q;
  cin>>q;
  for(ll i=0; i<q; i++){
  	ll b,c;
  	cin>>b>>c;
  	ll freq = f[b];
  	f[b]=0;
  	f[c]+=freq;
  	sum = sum-freq*b+freq*c;
  	cout<<sum<<'\n';
  }
  return 0;
}

Measured memory_bytes: 4420
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

N = int(input())
A = list(map(int, input().split()))

counter = Counter(A)
ans = sum(i * (i - 1) // 2 for i in counter.values())

for a in A:
    c = counter[a]
    print(ans - c * (c - 1) // 2 + (c - 1) * (c - 2) // 2)




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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1<<29;
typedef long long ll;

int dp[100][2][100];//dp[keta][未満である][0でない数の個数]

struct UnionFind {
  vi parent;
  UnionFind(int N) : parent(N) {
    rep(i, N)parent[i] = i;
  }

  int getRoot(int child){
    return ((parent[child] == child) ? child : parent[child] = getRoot(parent[child]));
  }
  void unite(int x, int y){
    int root_x = getRoot(x);
    int root_y = getRoot(y);
    if(root_x == root_y)return;
    parent[root_x] = parent[root_y];
  }
  bool isSame(int x, int y){
    return getRoot(x) == getRoot(y);
  }
};

ll fi(ll ans, ll t){
    return (t == 0) ? ans : fi(t, ans % t);
}

ll lcm(ll ans, ll t){
    return ans / fi(ans, t) * t ;
}

int main(){
    int N;cin >> N;
    ll T[N];
    ll maxv = 0;
    rep(i, N){cin >> T[i];if(maxv < T[i])maxv = T[i];}
    ll ans = maxv;
    rep(i, N){
        if(ans % T[i] == 0)continue;
        ans = lcm(ans, T[i]);
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
 using namespace std;
 struct Card {char suit, value;};
 void bubble_sort(struct Card A[],int len)
{
    int i,j;
    for(i=0;i<len-1;i++)
    {
        for(j=0;j<len-1-i;j++)
            if(A[j].value>A[j+1].value)
            {
                swap(A[j], A[j+1]);//不只是value要换，suit也要换

            }

    }
}
void selection_sort(struct Card A[], int len)
{
    int i,j;

	for (i = 0 ; i < len - 1 ; i++)
    {
		int min = i;
		for (j = i + 1; j < len; j++)     //走訪未排序的元素
		{
			if (A[j].value <A[min].value)    //找到目前最小值
			{
				min = j;    //紀錄最小值
			}
		}

	   	 swap(A[i],A[min]);

    }
}
void print(struct Card A[],int N)
{
    for(int i=0;i<N;i++)
    {
        if(i>0) cout<<" ";
        cout <<A[i].suit<<A[i].value;
    }
    cout<<endl;
}
bool isStable(struct Card c1[],struct Card c2[],int N)
{
    for(int i=0;i<N;i++)
    {
        if(c1[i].suit!=c2[i].suit) return false;

    }
    return true;
}
int main()
{
    Card C1[100],C2[200];
    int N;
    char ch;
    cin>>N;
     for(int i=0;i<N;i++)
     {
         cin>>C1[i].suit>>C1[i].value;
     }
      for(int i=0;i<N;i++)  C2[i]=C1[i];
      bubble_sort(C1,N);
      selection_sort(C2,N);

      print(C1, N);
      cout<<"Stable"<<endl;
     print(C2, N);
       if ( isStable(C1,C2,N) )
        {
            cout<<"Stable"<<endl;
        }
      else
      {
          cout<<"Not stable"<<endl;
      }
      return 0;
}



Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<chrono>
#include<random>
#include<cstdio>
#include<set>
#include<map>
#include<numeric>
#include<cfenv>
#include<cmath>
#define MAX_N pow(10,6)
#define MAX_M pow(10,6)
#define INF pow(10,6)
#define REP(i,n) for(long long i=0;i<n;i++)
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin>>N;
    string S,T;
    cin>>S>>T;
    REP(i,N){
        cout<<S[i]<<T[i];
    }
}

Measured memory_bytes: 888
S = input ()
if S == "SAT":
  print (1)
if S == "FRI":
  print (2)
if S == "THU":
  print (3)
if S == "WED":
  print (4)
if S == "TUE":
  print (5)
if S == "MON":
  print (6)
if S == "SUN":
  print (7)


Measured memory_bytes: 3060
import copy

n, l = map(int,  input().split())

s = [x + l for x in range(n)]
num = sum(s)
b = abs(num - (num - s[0]))
test = num - s[0]

for i in range(1, n):
  a = copy.copy(s)
  a.remove(s[i])
  if(i != 0):
    if(min(b, abs(num - sum(a))) != b):
      test = sum(a)
      b = abs(num - sum(a))
  
print(test)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<31)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> s;
    int ans = 0;
    rep(i, 0, s.size()-1) {
        if (s[i] != s[i+1]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
int x[1180][118][118],n,m,p,a,b,c,i,j;main(){while(true){memset(x,0,sizeof(x));std::cin>>n>>m>>p;if(!n){break;}for(i=0;i<m;i++){std::cin>>a>>b>>c;x[a][b][c]=1;x[a][c][b]=1;}for(i=1000;i>0;i--){for(j=1;j<=n;j++){if(x[i][p][j]==1){p=j;break;}}}printf("%d\n",p);}}

Measured memory_bytes: 65332
#include<bits/stdc++.h>
using namespace std;
long long n,m,nd;
int main()
{
    cin>>n>>m;
    nd=2*n;
    if(nd>m)cout<<m/2<<endl;
    else if(nd==m)cout<<n<<endl;
    else
    {
        m-=nd;
        m/=4;
        cout<<n+m<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from collections import deque
from collections import Counter
import bisect
from collections import defaultdict
import itertools
def main():
    mod = 998244353
    N, K = MI()
    sec = []
    for i in range(K):
        l, r = MI()
        sec.append((l, r))
    dp = [0 for _ in range(N + 1)]
    dpsum = [0 for _ in range(N + 1)]
    dp[0] = 1
    dpsum[0] = 1
    for i in range(1, N):
        for j in range(K):
            li = i - sec[j][1]
            ri = i - sec[j][0]
            if ri < 0:
                continue
            li = max(li, 0)
            dp[i] += (dpsum[ri] - dpsum[li - 1]) % mod
            dp[i] %= mod
        dpsum[i] = (dpsum[i - 1] + dp[i]) % mod
    print(dp[N - 1])
if __name__ == "__main__":
    main()



Measured memory_bytes: 102332
a,b,m = map(int,input().split())
aaa = list(map(int,input().split()))
bbb = list(map(int,input().split()))

ans = 3*(10**5)

for _ in range(m):
  x,y,c = map(int,input().split())
  x-=1; y-=1
  ans = min(ans,aaa[x]+bbb[y]-c)

aaa = sorted(aaa)
bbb = sorted(bbb)

ans = min(ans,aaa[0]+bbb[0])
print(ans)
  

Measured memory_bytes: 18612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    ll x;
    cin >> x;
    cout << (x / 500) * 1000 + ((x % 500) / 5) * 5 << endl;
}


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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;cin>>n;
    vector<int> l(2*n);
    rep(i,(2*n)) cin>>l[i];
    sort(ALL(l));
    
    ll ans=0;
    rep(i,2*n){
        if(i%2==0) ans+=l[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x; cin >> x;
    ll ans = x/11 *2;
    x %= 11;
    if(x>6) ++ ans;
    if(x>0) ++ ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define all(x) (x).begin(), (x).end()
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  //cout << fixed << setprecision(15)

  ll r, c, k;
  cin >> r >> c >> k;
  vector<vector<ll>> item(r, vector<ll>(c, 0));
  for (int i = 0; i < k; i++) {
    ll u, v, p;
    cin >> u >> v >> p;
    u--, v--;
    item[u][v] = p;
  }

  vector<vector<vector<ll>>> dp(2, vector<vector<ll>>(c, vector<ll>(4))); //dp[i][j][k]: (i, j)にたどり着いた時点でその行でちょうどのこりk個取れるとき

  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      if (1) { //全部の場合では？
        for (int k = 0; k < 4; k++) {
          //cout << "!!1" << endl;
          if (j+1 < c) dp[i%2][j+1][k] = max(dp[i%2][j][k], dp[i%2][j+1][k]);
          if (i+1 < r) dp[(i+1)%2][j][3] = max(dp[i%2][j][k], dp[(i+1)%2][j][3]);
        }
      }
      if (item[i][j] != 0) {
        for (int k = 1; k < 4; k++) {
          //cout << "!!2" << endl;
          if (j+1 < c) dp[i%2][j+1][k-1] = max(dp[i%2][j][k] + item[i][j], dp[i%2][j+1][k-1]);
          if (i+1 < r) dp[(i+1)%2][j][3] = max(dp[i%2][j][k] + item[i][j], dp[(i+1)%2][j][3]);
        }
        //k=0のとき
        //cout << "!!3" << endl;
        if (j+1 < c) dp[i%2][j+1][0] = max(dp[i%2][j][0] + 0, dp[i%2][j+1][0]);
        if (i+1 < r) dp[(i+1)%2][j][3] = max(dp[i%2][j][0] + 0, dp[(i+1)%2][j][3]);
      }
      //for (int k = 0; k < 4; k++) dp[i%2][j][k]  = 0;
    }

    /*for (int ii = 0; ii < 2; ii++) {
      for (int j = 0; j < c; j++) {
        for (int k = 0; k < 4; k++) {
          cout << dp[ii][j][k] << ",";
        }
        cout << "  ";
      }
      cout << endl;
    }*/
    if (i != r-1) for (int j = 0; j < c; j++) for (int k = 0; k < 4; k++) dp[i%2][j][k] = 0;
  }

  /*
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < c; j++) {
      for (int k = 0; k < 4; k++) {
        cout << dp[i][j][k] << ",";
      }
      cout << "  ";
    }
    cout << endl;
  }

  cout << "ok" << endl;
  */

  if (item[r-1][c-1] == 0) {
    ll ans = 0;
    for (int k = 0; k < 4; k++) {
      //cout << dp[r-1][c-1][k] << " ";
      ans = max(ans, dp[(r-1)%2][c-1][k]);
    }
    cout << ans << endl;
    return 0;
  }
  else {
    ll ans = dp[(r-1)%2][c-1][0];
    for (int k = 1; k < 4; k++) {
      ans = max(ans, dp[(r-1)%2][c-1][k] + item[r-1][c-1]);
    }
    cout << ans << endl;
    return 0;
  }
}


Measured memory_bytes: 74328
#include <iostream>

using namespace std;

int main()
{
	int K, A, B;
	//int n;

	cin >> K >> A >> B;
	int num = 0;
	bool check = false;
	while (1)
	{
		num += K;
		if (num <= B && num >= A)
		{
			check = true;
			break;
		}

		if (num > B)
		{
			break;
		}
	}


	if (check)
	{
		cout << "OK" << endl;
	}
	else {
		cout << "NG" << endl;
	}


	return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int ans,n,h,w;
int a[10000],b[10000];
int main(){
    cin>>n>>h>>w;;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }

    for(int i=0;i<n;i++){
        if(a[i]>=h&&b[i]>=w)ans++;
    }
    cout<<ans<<endl;
}


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

int main(void) {
    int X;
    cin>>X;
    int cnt = X / 100;
    int amari = X % 100; // 調整が必要な金額
    if (cnt == 0) {
        cout << "0" << endl;
        return 0;
    } else if (cnt >= 100) {
        cout << "1" << endl;
        return 0;
    }
    // 0
    for (int i = 0; i <= cnt; i++) {
        // 1
        for (int j = 0; j <= cnt - i; j++) {
            // 2
            for (int k = 0; k <= cnt - i - j; k++) {
                // 3
                for (int l = 0; l <= cnt - i - j - k; l++) {
                    // 4
                    for (int m = 0; m <= cnt - i - j - k - l; m++) {
                        // 5
                        if (0 * i + 1 * j + 2 * k + 3 * l + 4 * m + 5 * (cnt - i - j - k - l - m) == amari) {
                            cout << "1" << endl;
                            return 0;
                        }
                    }
                }
            }
        }
    }
    cout << "0" << endl;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
rr = lambda: stdin.readline().strip()
rrM = lambda: map(int, rr().split())

A,B,C = rrM()
ans = 0
while A%2==B%2==C%2==0 and ans < 10000:
    ans += 1
    A,B,C = sorted([(A+B)/2,(B+C)/2,(C+A)/2])

if ans == 10000: ans = -1
print ans


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n, m;
    cin >> n >> m;
    vi a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    vpii ab(n);
    rep(i, n) {
        ab[i].first = a[i];
        ab[i].second = b[i];
    }
    VSORT(ab);
    ll ans = 0;
    rep(i, n) {
        int buy = min(m, ab[i].second);
        ans += (ll)buy * ab[i].first;
        m -= buy;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      s: chars,
    }
    let mut ans = 1000;
    for i in 0..s.len()-2 {
        let a: usize = s[i].to_string().parse().unwrap();
        let b: usize = s[i+1].to_string().parse().unwrap();
        let c: usize = s[i+2].to_string().parse().unwrap();
        let d  = ((a*100+b*10+c) as i64 - 753).abs();
        ans = min(ans, d);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;
public class Main{

	public static void main(String[] args) {
		// TODO 自动生成的方法存根
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int K=sc.nextInt();
        int X=sc.nextInt();
        int Y=sc.nextInt();
        int Total=0;
        if(N>K) {
        	Total=(K*X)+(N-K)*Y;
        	System.out.println(Total);
        }else {
        	Total=N*X;
        	System.out.println(Total);
        }
	}

}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);
    int mod = 1000000007;

    int n;
    cin>>n;
    vector<int> a(n);

    long long sum=0;
    for(int i=0; i<n; i++){
        cin>>a[i];
        sum+=a[i];
        sum%=mod;
    }
    
    long long ans=0;
    for(int i=0; i<n; i++){
        sum-=a[i];
        if(sum<0)   sum+=mod;
        ans+=a[i]*sum;
        ans%=mod;
    }
    
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3996
use proconio::input;
fn main() {    
    input!{
        a: i32, b: i32, c:i32
    }    
    if (0..b).any(|x| (x*(a%b) - c)%b == 0){
        println!("YES")
    }
    else{
        println!("NO")
    }
}


Measured memory_bytes: 2108
#include <iostream>

using namespace std;

int main(){
        int a, b, c, k; cin>>a>>b>>c>>k;
        int ans=0;
        while(k){
            if(a){
                if(a>=k){
                    ans+=k;
                    a-=k;
                    k=0;
                }
                else{
                    ans+=a;
                    k-=a;
                    a=0;
                }
            }
            else if(b){
                if(b>=k){
                    b-=k;
                    k=0;
                }
                else{
                    k-=b;
                    b=0;
                }
            }
            else if(c){
                if(c>=k){
                    ans-=k;
                    c-=k;
                    k=0;
                }
                else{
                    ans-=c;
                    k-=c;
                    c=0;
                }
            }
        }
        cout<<ans;
        return 0;
}


Measured memory_bytes: 3636
n = int(input())
for i in range (1,n + 1):
    if i % 3 == 0:
        print(" " + str(i),end = "")
    else:
        i = str(i)
        l = len(i)
        for j in range (l):
            if int(i[j]) == 3:
                print(" " + i,end = "" )
                break
print()


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

void bomb(int x, int y, char field[8][9]) {
    field[y][x] = '0';
    for (int i = x - 3; i <= x + 3; i++) {
        if (0 <= i && i < 9 && field[y][i] == '1') {
            bomb(i, y, field);
        }
    }
    for (int i = y - 3; i <= y + 3; i++) {
        if (0 <= i && i < 9 && field[i][x] == '1') {
            bomb(x, i, field);
        }
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        char field[8][9];
        for (int j = 0; j < 8; j++) {
            cin >> field[j];
        }
        int x, y;
        cin >> x >> y;
        bomb(x - 1, y - 1, field);
        cout << "Data " << i + 1 << ":" << endl;
        for (int j = 0; j < 8; j++) {
            for (int k = 0; k < 8; k++) {
                cout << field[j][k];
            }
            cout << endl;
        }
    }
}

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

int main() {

	int W, H, N;
	cin >> W >> H >> N;

	vector<int> x(N), y(N), a(N);

	for (int i = 0;i < N;i++) {
		cin >> x.at(i) >> y.at(i) >> a.at(i);
	}

	vector<vector<int>> coo(H , vector<int>(W));

	for (int i = 0;i < N;i++) {
		if (a.at(i) == 1 && x.at(i) != 0) {
			for (int j = 0;j < x.at(i);j++) {
				for (int k = 0;k < H;k++) {
					coo.at(k).at(j)++;
				}
			}
		}
		if (a.at(i) == 2 && x.at(i) != W) {
			for (int j = x.at(i);j < W;j++) {
				for (int k = 0;k < H;k++) {
					coo.at(k).at(j)++;
				}
			}
		}
		if (a.at(i) == 3 && y.at(i) != 0) {
			for (int j = H-y.at(i);j < H;j++) {
				for (int k = 0;k < W;k++) {
					coo.at(j).at(k)++;
				}
			}
		}
		if (a.at(i) == 4 && y.at(i) != H) {
			for (int j = 0;j < H-y.at(i);j++) {
				for (int k = 0;k < W;k++) {
					coo.at(j).at(k)++;
				}
			}
		}
	}

	int ans = 0;
	for (int i = 0;i < H;i++) {
		for (int j = 0;j < W;j++) {
			if (coo.at(i).at(j) == 0)
				ans++;
		}
	}
	cout << ans;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    // int A[100000];
    for (int i = 0; i < M; i++)
    {
        cin >> A[i];
        N -= A[i];
    }
    if(N < 0)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << N << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3668
#include"bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>

using namespace std;

#define MAX 500002

int n;
char buf[MAX];
string s;

int dp[MAX][3];  //0 nothing 1 10+cur 2 cur (but no 01)

int main() {
	cin >> n;
	scanf("%s", buf);
	s = buf;
	memset(dp, -1, sizeof(dp));
	dp[0][0] = 0;
	dp[0][2] = 0;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < 3; j++) {
			if (dp[i][j] == -1)continue;
			if (j == 0) {
				if (s[i] == '0') {
					dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
					continue;
				}
				dp[i + 1][0] = max(dp[i + 1][0], dp[i][j]);
				if (s[i] == '1') {
					dp[i + 1][2] = max(dp[i + 1][2], dp[i][j] + 1);
				}
				if (i + 1 < s.size() && s[i] == '1'&&s[i + 1] == '0') {
					dp[i + 2][1] = max(dp[i + 2][1], dp[i][j]);
				}
				continue;
			}
			if (j == 1) {
				if (i + 1 < s.size() && s[i] == '1'&&s[i + 1] == '0') {
					dp[i + 2][1] = max(dp[i + 2][1], dp[i][j]);
				}
				if (s[i] == '0') {
					dp[i + 1][0] = max(dp[i + 1][0], dp[i][j]);
					continue;
				}
				dp[i + 1][0] = max(dp[i + 1][0], dp[i][j]);
				dp[i + 1][1] = max(dp[i + 1][1], dp[i][j] + 1);
				dp[i + 1][2] = max(dp[i + 1][2], dp[i][j]+1);
				continue;
			}
			if (i + 1 < s.size() && s[i] == '0'&&s[i + 1] == '1') {
				dp[i + 2][0] = max(dp[i + 2][0], dp[i][j]);
			}
			if (s[i] == '1') {
				dp[i + 1][2] = max(dp[i + 1][2], dp[i][j] + 1);
			}
		}
	}
	if (max(dp[s.size()][0], dp[s.size()][1]) == -1) {
		return 1;
	}
	cout << max(dp[s.size()][0], dp[s.size()][1]) << endl;
	return 0;
}

Measured memory_bytes: 7040
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 10000000
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat() float64 {
	sc.Scan()
	f, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func main() {
	k, n := nextInt(), nextInt()
	a := make([]int, n+1)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	a[n] = k + a[0]

	max := -1
	sum := 0
	for i := 1; i <= n; i++ {
		dist := a[i] - a[i-1]
		sum += dist
		if dist > max {
			max = dist
		}
	}
	fmt.Println(sum - max)
}


Measured memory_bytes: 3840
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
using namespace std;
int main(void){
    int a,b,c,x;
    cin>>a>>b>>c>>x;
    int ans=0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int k=0;k<=c;k++){
                if(500*i+100*j+50*k==x)ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin >> n;
	ll p[n],sum=0;
	for(int i=0; i<n; i++){
		cin >> p[i];
		sum+=p[i];
	}
	sort(p,p+n);
	sum-=(p[n-1])/2;
	cout << sum;
	return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * overflow (ll vs int?)
 * * array bounds
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */


Measured memory_bytes: 256
n = int(input())
s = input()
e_cnt = 0
for i in range(n):
    if s[i] == "E":
        e_cnt += 1
ans = e_cnt
w_cnt = 0
for i in range(n):
    if s[i] == "E":
        e_cnt -= 1
        
    ans = min(w_cnt + e_cnt, ans)
    if s[i] == "W":
        w_cnt += 1

print(ans)




Measured memory_bytes: 3668
// ABC129_D
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll A, B, C;
    cin >> A >> B >> C;
    
    // calculation
    cout << (A+B+C) - max({A, B, C}) << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<int> dy={1,0,-1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main(){
    int n,m;
    cin>>n>>m;
    vector<ll> x(n),y(n),z(n);
    rep(i,n) cin>>x[i]>>y[i]>>z[i];
    
    ll ans=0;
    rep(p,2){
        rep(q,2){
            rep(r,2){
                vector<ll> vec(n);
                rep(i,n){
                    vec[i]=(ll)x[i]*(2*p-1)+y[i]*(2*q-1)+z[i]*(2*r-1);
                }
                sort(all(vec),greater<ll>());
                ll now=0;
                rep(i,m){
                    now+=vec[i];
                }
                ans=max(ans,now);
            }
        }
    }
    cout<<ans<<endl;
    
    
}


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

    class Program
    {
        static void Main(string[] args)
        {
            var Q = int.Parse(Console.ReadLine());
            var primes = new bool[100001];
            primes[2] = true;
            for (var i = 3;i<primes.Length;i=i+2)
            {
                primes[i] = true;
            }
            for(var i = 3;i<primes.Length;)
            {
                for (var k = i; k < primes.Length; k = k + i)
                {
                    if (!primes[k]) continue;
                    if(k%i==0&&i!=k)
                    {
                        primes[k] = false;
                    }
                }
                for(i++; i<primes.Length; i++)
                {
                    if (primes[i]) break;
                }
            }

            var nearNum = new int[100002];
            for (var i = 3; i < primes.Length;i++)
            {
                nearNum[i] = primes[i]&& primes[(i+1)/2] ? nearNum[i - 1] + 1 : nearNum[i - 1];
            }

            for(var i =0;i<Q;i++)
            {
                var lr = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
                var l = lr[0];
                var r = lr[1];
                Console.WriteLine(nearNum[r] - nearNum[l-1]);
            }
        }
    }

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,A[202020];
ll i, j, k,ans;
int main(){
    scanf("%lld", &N);
    j = 0;
    fornum(i,0,N){
        scanf("%lld", &A[i]);
        A[i] -= i + 1;
    }
    sort(A, A + N);
    ll b = A[N / 2];
    fornum(i,0,N){
        ans += abs(A[i] - b);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(void) {
	int a, b, c, d;
	cin >> a;
	d = a % 10;
	a /= 10;
	c = a % 10;
	a /= 10;
	b = a % 10;
	a /= 10;
	if (a + b + c + d == 7)
		printf("%d+%d+%d+%d=7", a, b, c, d);
	else if (a + b + c - d == 7)
		printf("%d+%d+%d-%d=7", a, b, c, d);
	else if (a + b - c + d == 7)
		printf("%d+%d-%d+%d=7", a, b, c, d);
	else if (a + b - c - d == 7)
		printf("%d+%d-%d-%d=7", a, b, c, d);
	else if (a - b + c + d == 7)
		printf("%d-%d+%d+%d=7", a, b, c, d);
	else if (a - b + c - d == 7)
		printf("%d-%d+%d-%d=7", a, b, c, d);
	else if (a - b - c + d == 7)
		printf("%d-%d-%d+%d=7", a, b, c, d);
	else if (a - b - c - d == 7)
		printf("%d-%d-%d-%d=7", a, b, c, d);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int main(void){
	char in[100];
	int i,j,size,ans,data[100],com,com2=0;

	for(i=0;i<100;i++)	data[i]=0;

	while(scanf("%s",in)!=EOF){
		for(i=0;i<100;i++){
			if(in[i]=='\0')	break;
		}
		size=i;
		for(i=0;i<100;i++)	data[i]=0;
		for(i=0;i<size;i++){
			if(in[i]=='I')	data[i]=1;
			if(in[i]=='V')	data[i]=5;
			if(in[i]=='X')	data[i]=10;
			if(in[i]=='L')	data[i]=50;
			if(in[i]=='C')	data[i]=100;
			if(in[i]=='D')	data[i]=500;
			if(in[i]=='M')	data[i]=1000;
		}
		
		ans=data[0];
		for(i=0;i<size;i++){
			if(data[i]>=data[i+1])	ans+=data[i+1];
			if(data[i]<data[i+1]){
				ans-=data[i];
				com=data[i];
				for(j=i+1;j<size;j++){
					com2+=data[j];
					if(data[j]<data[j+1])	break;
					i++;
				}
				ans+=com2-com;
				com2=0;
			}
		}
		printf("%d\n",ans);
	}

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<string.h>
using namespace std;

int main(){
	int n, len;
	char str[257] = {}, str_c[257];
	cin >> n;
	getchar();
	for (int m = 0; m < n; m++){
		int flag = false;
		gets(str);
		len = strlen(str);
		//printf("%d\n", len);
		for (int i = 0; i < 26; i++){
			/*if (i % 2 == 0 || i % 13 == 0) continue;*/
			for (int j = 0; j < 26; j++){
				for (int k = 0; k <= len; k++){
					if (isalpha(str[k])){
						str[k] -= 'a';
						str_c[k] = (str[k] * i + j) % 26 + 'a';
						str[k] += 'a';
					}
					else{
						str_c[k] = str[k];
					}
				}
				if (strstr(str_c, "this") || strstr(str_c, "that")){
					printf("%s\n", str_c);
					flag = true;
					break;
				}
			}
			if (flag) break;
		}
	}
	return 0;
}

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

class UnionFind{
public:
    vector<int> par;
    vector<int> siz;

    UnionFind(int k) : par(k), siz(k, 1){
        for(int i = 0; i < k; i++) par[i] = i;
    }

    int root(int x){
        if(par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;

        if(siz[x] < siz[y]) swap(x, y);
        par[y] = x;
        siz[x] += siz[y];
        return;
    }

    bool same(ll x, ll y){
        return root(x) == root(y);
    }

    int size(int x){
        return siz[root(x)];
    }
};

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        uf.unite(a, b);
    }
    int ans = 1;
    for(int i = 0; i < n; i++) {
        ans = max(ans, (int) uf.size(i));
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 256