akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
using db = double;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
  数値型から文字列に変換　to_string(number);これは簡単
  文字列から数値型に変換　stoi(number)
  文字列からllに変換　stoll(number)
  __gcd(a,b)は最大公約数を取ってくれる、aとb
  の大きい方をNとしたとき、計算量はlog N (この書き方、底は２）
 */
const int mod = 1e9 + 7;
//ここから書き始める


//関数の定義はここ

int main(){
	int n; 
	cin >> n;

	//要素数nの配列を作るテンプレート
	vector<int> A(n);
	for(int i = 0 ; i < n; i ++){
		cin>>A[i];
	}
	int m ;cin>>m;
	rep(i,m){
		int p,x;
		cin >> p>>x;
		ll ans = 0;
		rep(j,n){
			if(j+1==p){
				ans += x;
			}
			else{
				ans +=A[j];
			}
		}
		cout<<ans<<endl;
	}


}


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

int N,H,d,h;

int main(){
  scanf("%d%d",&N,&H);
  ll ans = 0;

  ll cur = H;
  priority_queue<pll> q;
  for(int i=0;i<N-1;i++){

    scanf("%d%d",&d,&h);
    ll rem = H-cur;
    priority_queue<pll> tmp;
    while(q.size() && q.top().first >= h){
      pll p = q.top(); q.pop();
      rem -= p.second * p.first;
      tmp.push(p);
    }
    swap(q,tmp);
    ll times = rem/h;
    if(times)q.push(pll(h,times));
    if(times*h != rem)q.push(pll(rem-times*h,1));

    cur -= d;
    while(cur<=0){
      pll p = q.top(); q.pop();
      ll need = -cur/p.first+1;

      if(need <= p.second){
	ans += need;
	p.second -= need;
	cur += need * p.first;
	if(p.second)q.push(p);
      }else{
	ans += p.second;
	cur += p.first * p.second;
      }
    }
  }

  printf("%lld\n",ans);
}

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

typedef long long ll;
using namespace std;

int main()
{  
    string s;

    cin >> s;

    for(int i=0; i<s.size(); i++){
        if(s[i] == '1')s[i] = '9';
        else if(s[i] == '9')s[i] = '1';
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 768
using System;

public class Test
{
    public static void Main(string[] args)
    {

        int a,b;
        string[] str = Console.ReadLine().Split(' ');
        a = int.Parse(str[0]);
        b = int.Parse(str[1]);
        Console.WriteLine("{0} {1}", a*b, 2 * (a + b));

    }
}


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

const int INF = 1001001001;

int main()
{
    int N, W, max_v = -1, ans = 0;
    cin >> N >> W;
    vector<int> v(N), w(N);
    for(int i=0;i<N;++i) 
    {
        cin >> v[i] >> w[i];
        max_v = max(max_v, v[i]);
    }
    vector< vector<int> > dp(N+1, vector<int>(N*max_v+1, INF));

    dp[0][0] = 0;

    for(int i=0;i<N;++i)
    {
        for(int j=0;j<N*max_v+1;++j)
        {
            if(j >= v[i] && dp[i][j - v[i]] + w[i] <= W){
                dp[i+1][j] = min(dp[i][j - v[i]] + w[i], dp[i][j]);
                ans = max(ans, j);
            }
            else{
                dp[i+1][j] = dp[i][j];
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 6844
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
using namespace std;

int main(){
	string s;
	cin >> s;

	s[5] = ' ';
	s[13] = ' ';

	cout << s << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) FOR(i,0,n)
#define INF (1<<29)

struct SegmentTree {
	int init_val;
	int n;
	vector<int> dat;
	
	SegmentTree(int _n) {
		init_val = INF;
		n = 1;
		while (n < _n) n *= 2;
		dat.clear();
		dat.resize(2 * n - 1, init_val);
	}
	
	void update(int k, int a) {
		k += n - 1;
		dat[k] = min(dat[k], a);
		
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = min(dat[2 * k + 1], dat[2 * k + 2]);
		}
	}
	
	int query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return init_val;
		if (a <= l && r <= b) return dat[k];
		return min(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
	}
	
	int query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
};

typedef pair<int, int> pii;
typedef pair<int , pii> pip;
typedef SegmentTree Seg;
typedef long long ll;

int main() {
	int n, d;
	cin >> n >> d;
	vector<pip> stars(n);
	REP(i, n) {
		int x, y, b;
		scanf("%d %d %d", &x, &y, &b);
		stars[i] = pip(b, pii(x, y));
	}
	sort(stars.begin(), stars.end());
	
	Seg up(n), down(n), right(n), left(n);
	REP(i, n) {
		int x = stars[i].second.first;
		int y = stars[i].second.second;
		
		up.update(i, -y);
		down.update(i, y);
		right.update(i, -x);
		left.update(i, x);
	}
	
	int st = 0, en = 0;
	ll ans = 0;
	
	while (st < n) {
		if (en - st > 0 && stars[en].first - stars[st].first <= d) {
			ll  s = (ll)(-up.query(st, en + 1) - down.query(st, en + 1))
				    * (-right.query(st, en + 1) - left.query(st, en + 1));
			ans = max(ans, s);

			if (en == n - 1) st++;
			else en++;
			
		}
		else if (stars[en].first - stars[st].first > d) st++;
		else if (en < n - 1) en++;
		else st++;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 11760
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using Graph = std::vector<std::vector<int> >;
const int INF = 1e17;
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	std::string s;
	std::cin >> s;
	rep(i,n) {
		if(s[i]=='R') s[i]='A';
		if(s[i]=='G') s[i]='C';
	}
	std::vector<std::vector<int> > ac(3,std::vector<int>(n+1,0));
	// go through all of the j,k and count i
	rep(c,3) {
		rep(i,n) {
			ac[c][i+1] = ac[c][i] + (s[i]==(char)('A'+c));
		}
	}
	int count=0;
	for(int j=1;j<n-1;j++) {
		for(int k=j+1;k<n;k++) {
			if(s[j]==s[k]) continue;
			int c = ((s[j]-'A'+1)^(s[k]-'A'+1))-1;
			count+=ac[c][j];
			if(2*j-k>=0 && s[2*j-k]==(char)(c+'A')) {
				count--;
			}
		}
	}
	print(count);
	return 0;
}


Measured memory_bytes: 3740
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

struct UnionFind{
  vector<int> par;
  vector<int> sizes;

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

  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  long long int size(int x) {
    return sizes[find(x)];
  }
};

int main(){

  ll n;
  cin >> n;
  
  ll x[n],y[n];
  for(ll i=0;i<n;i++)cin >> x[i] >> y[i];

  //x座標、y座標,町番号
  vector<tuple<ll,ll,ll>> N(n);
  for(ll i=0;i<n;i++)N[i]=make_tuple(x[i],y[i],i);

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

  //道
  vector<tuple<ll,ll,ll>> G;

  for(ll i=0;i<N.size()-1;i++){
    G.push_back(make_tuple(get<0>(N[i+1])-get<0>(N[i]),get<2>(N[i]),get<2>(N[i+1])));
  }

  for(ll i=0;i<n;i++)N[i]=make_tuple(y[i],x[i],i);

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

    for(ll i=0;i<N.size()-1;i++){
    G.push_back(make_tuple(get<0>(N[i+1])-get<0>(N[i]),get<2>(N[i]),get<2>(N[i+1])));
  }

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

  UnionFind tree(n);
  ll s=0;

  for(int i=0;i<G.size();i++){
    if(tree.same(get<1>(G[i]),get<2>(G[i])));
    else{
      tree.unite(get<1>(G[i]),get<2>(G[i]));
      s+=get<0>(G[i]);
    }
  }

  cout << s <<endl;




}

Measured memory_bytes: 12400
// Ivan Zanov
// Template
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std :: chrono;
#define lowest_bit(x) ((x)&((x)^((x)-1)))
#define max(a,b) (a<b?b:a)
#define min(a,b) (a<b?a:b)
#define IOS ios_base::sync_with_stdio(0);
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define INF (int)1e9
#define EPS (int)1e-9
#define bit_count __builtin_popcount
#define gcd __gcd
#define max3(a, b, c) max(a, max(b,c))
#define min3(a, b, c) min(a, min(b,c))
#define abs(x) (x < 0 ? (-x) : x)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
inline void set_bit(int & n, int b) { n |= (1 << (int) b); }
inline void unset_bit(int & n, int b) { n &= ~(1 << (int) b); }
inline bool check_bit(int n, int pos) { return ( n & (1 << (pos))); }
inline ll lcm(ll a, ll b){ return (a * b / gcd(a,b));}
inline ll square(ll a){return (a * a);}
int main() {
	string str;
	cin>>str;
	bool yymm = false, mmyy = false;
	if((int(str[0] - '0') == 1 && int(str[1] - '0')<=2) || (int(str[0] - '0') == 0 && int(str[1] - '0') > 0))
		mmyy = true;
	if((int(str[2] - '0') == 1 && int(str[3] - '0')<=2) || (int(str[2] - '0') == 0 && int(str[3] - '0') > 0))
		yymm = true;
		
	if(yymm && mmyy)
		cout<<"AMBIGUOUS"<<endl;
	else if(yymm && !mmyy)
		cout<<"YYMM"<<endl;
	else if(!yymm && mmyy)
		cout<<"MMYY"<<endl;
	else	
		cout<<"NA"<<endl;
	//auto start = high_resolution_clock::now();
	/*auto end = high_resolution_clock::now();
	auto duration = duration_cast<microseconds>(stop - start);
	cout<<fixed<<setprecision(3)<<duration.count() * 1e-6<<endl;*/
    return 0;
}

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

int main() {
	int N, A;
  	cin >> N >> A;
  //宿題の個数を宣言と宿題にかかる日数を代入
    vector<int> SYUKU(N);
  	for (int i = 0; i < A; i++) {
      cin >> SYUKU.at(i);
    }
  //宿題を終わらすのにかかる日にちの合計値
  int OWARI = 0;
  for (int i = 0; i < A; i++) {
    OWARI += SYUKU.at(i);
  }
  //夏休み全日から宿題を終わらす日にちを引いて終わるならその日数終わらないなら-1を代入する
  if (OWARI <= N) {
    cout << N - OWARI << endl;
  }
  else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 7220
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int count=0,flag=0;
    if(n>1)
    {
        count=(n*(n-1))/2;
    }
    if(m>1)
    {
       flag=(m*(m-1))/2;
    }
   cout<<flag+count;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 3e18;
const double INFD = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 200005;
const int MAXV = 50000;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
char text[MAXN];
int arr[MAXN];

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++) {
        arr[i] = read<int>();
    }
    sort(arr, arr + n);
    ll sum = 0;
    for (int i = 0; i < k; i++) {
        sum += arr[i];
    }
    printf("%lld", sum);
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int> > vvint;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;
typedef priority_queue<int, vector<int>, greater<int> > spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll> > spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int> > bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll> > bpqll;        //大きい順に取り出し

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){
    cout << "Yes" << endl;
}
void no(){
    cout << "No" << endl;
}
//-----------------------------------------

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

    int a, b ;
    cin >> a >> b ;
    cout << a* b <<endl;
    

    return 0;
}



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

#define f(i,a,b) for( ll  i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter   ios::sync_with_stdio(false);cin.tie(0)

// policy-based



using namespace std;


typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;



 
const ll MAX = 2e6+1;
const ll inf = 1e9;
const ll mod = 998244353;

ll tree[MAX*2];

ll l[20],r[20],n,k;

void update(ll l,ll r,ll v){
	for(l+=n,r+=n;l<r;l>>=1,r>>=1){
		if(l&1) (tree[l++] += v)%=mod;
		if(r&1) (tree[--r] += v)%=mod;
	}
}

ll query(ll x){
	ll ans = 0;
	x+=n;
	while(x) (ans += tree[x])%=mod, x>>=1;
	return ans;
}

int main(){
	fastio;
	cin >> n >> k;
	f(i,0,k) cin >> l[i] >> r[i];
	update(0,1,1);
	f(i,0,n){
		ll aux = query(i);
		f(j,0,k) update(i+l[j],i+r[j]+1,aux);
	}
	cout << query(n-1) << endl;
	return 0;
} 

Measured memory_bytes: 8292
arr=[]
a,b=gets.chomp.split(" ").map(&:to_i)
arr=gets.chomp.split(" ").map(&:to_i)
if a-b > 0
  arr = arr.sort.slice(0, a-b)
  print("#{arr.inject(:+)}\n")
else
  print("0\n")
end

Measured memory_bytes: 21360
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int r=sc.nextInt();
		System.out.println(3*r*r);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<math.h>
#define rep(i,l,r) for(ll i=l;i<r;i++)
#define rew(i,l,r) for(ll i=r - 1;i>=l;i--)

typedef long long ll;

ll max(ll a, ll b) { return a > b ? a : b; }

int main() {
    ll N, W;
    scanf("%lld%lld", &N,&W);
    ll v[101], w[101];
    rep(i, 0, N) {
        scanf("%lld%lld", &w[i], &v[i]);
    }
    ll dp[100001]={};
    rep(i, 0, N) {
        rew(j, w[i],W+1) {
            dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
        }
    }
    printf("%lld", dp[W]);

    return 0;
}

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

int main() {
	int n;
    cin >> n;
    ll l[n];
    for (int i = 0; i < n; ++i) {
        cin >> l[i];
    }
    sort(l, l+n);
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            for (int k = j+1; k < n; ++k) {
                if(l[i] == l[j] || l[j] == l[k]) continue;
                if(l[i] + l[j] > l[k]) ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
int cnt[7];
int main(){
    long les,m,a,c,w;
    while(cin>>les,les){
        cin>>m>>a>>c>>w;
        int ch=0;
        long cc=0;
        int i=0;
        long k=m/a;
        if(m/c<les||k==0){
            cout<<"NA"<<endl;
            continue;
        }
        if(k>w)k=w;
        for(i=k;i>0;i--){
            cc=(m-i*a)/c;
            if(cc+i>=les) {
                ch=1;
                break;
            }
        }
        if(ch) cout<<i<<" "<<cc<<endl;
        else cout<<"NA"<<endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

/* 
75
25*3
5*5*3
15*5
*/
int main(){
	ll N; cin>>N;
	vector<ll> prime(98,0);
	rep1(k,N){
		ll i=2;
		ll tmp=k;
		while(tmp!=1){
			if(tmp%i==0){
				tmp/=i;
				prime[i]++;
			}
			else i++;
		}
	}
	ll now[5]={2,4,14,24,74};
	ll kind[5]={0,0,0,0,0};
	rep(i,5){
		rep1(j,97){
			if(prime[j]>=now[i]) kind[i]++;
		}
		//cout<<kind[i]<<endl;
	}
	cout<<kind[4]+kind[3]*(kind[0]-1)+(kind[1]-1)*kind[1]*(kind[0]-2)/2+(kind[1]-1)*kind[2];
}

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

int main(void)
{
  char str[21];
  int i, tmp, num;

  scanf("%s", str);

  i = 0;
  num = strlen(str) -1;
  
  while(i < num){
    tmp = str[i];
    str[i] = str[num];
    str[num] = tmp;
    i++;
    num--;
  }

  printf("%s\n", str);

  return 0;
}

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

int main(){
  int n,s;
  int r[20100];

  while(cin>>n >> s , n||s){
    for(int i=0;i<n;i++)cin >> r[i];

    sort(r,r+n);
    int ans = 0;
    for(int i=0;i<n;i++)
      ans += n - (int)(upper_bound(r+i+1,r+n,s-r[i]) - r);
    cout << ans << endl;
  }
}

Measured memory_bytes: 912
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<memory.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n;
  ll x;
  cin >> n >> x;
  ll a[n];
  rep(i,n){
    cin >> a[i];
  }
  ll ans=longinf;
  ll dp[n][n]={}; //dp[i][j]:the minimum of the time to chatch i-th monster whitin j-times rotation
  rep(i,n)rep(j,n)dp[i][j]=longinf;
  rep(i,n)dp[i][0]=a[i];
  for(int i=0;i<n;i++){
    for(int j=1;j<n;j++){
      ll temp=a[(i+j)%n];
      dp[i][j]=min(dp[i][j-1],temp);
    }
  }
  for(int i=0;i<n;i++){ //the times of rotations
    ll res=i*x;
    rep(j,n){
      res+=dp[j][i];
    }
    ans=min(ans,res);
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
const ll mod = (ll)1e9 + 7;
    
int main() {

    int n; cin >> n;
    vi v(n);
    forn(n) cin >> v[i];
    deque<int> d;
    for(int i = 0; i < n; i++) {
        if(i % 2 == 0) {
            d.push_back(v[i]);
        }
        else {
            d.push_front(v[i]);
        }
    }
    if(n % 2 == 0) {
        while(!d.empty()) {
            cout << d.front() << " ";
            d.pop_front();
        }
    }
    else {
        while(!d.empty()) {
            cout << d.back() << " ";
            d.pop_back();
        }
    }
    return 0;
}


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

long long H, W, N, X[3009], Y[3009], dp[3009][2], fact[200009], factinv[200009], mod = 1000000007;
vector<pair<long long, long long>>vec;

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 30; i++) {
		if ((b / (1LL << i)) % 2 == 1) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}

long long Div(long long a, long long b, long long m) {
	return (a * modpow(b, m - 2, m)) % m;
}

void init() {
	fact[0] = 1; for (int i = 1; i <= 200000; i++) fact[i] = (fact[i - 1] * i) % mod;
	for (int i = 0; i <= 200000; i++) factinv[i] = Div(1, fact[i], mod);
}

long long ncr(long long n, long long r) {
	return (fact[n] * factinv[r] % mod) * factinv[n - r] % mod;
}

int main() {
	cin >> H >> W >> N; init();
	for (int i = 1; i <= N; i++) {
		cin >> X[i] >> Y[i];
		vec.push_back(make_pair(X[i], Y[i]));
	}
	vec.push_back(make_pair(1, 1));
	vec.push_back(make_pair(H, W));
	sort(vec.begin(), vec.end());

	dp[0][0] = 1;
	for (int i = 0; i < vec.size(); i++) {
		for (int j = i + 1; j < vec.size(); j++) {
			if (vec[i].second > vec[j].second) continue;
			dp[j][1] += dp[i][0] * ncr(vec[j].first - vec[i].first + vec[j].second - vec[i].second, vec[j].second - vec[i].second);
			dp[j][0] += dp[i][1] * ncr(vec[j].first - vec[i].first + vec[j].second - vec[i].second, vec[j].second - vec[i].second);
			dp[j][0] %= mod; dp[j][1] %= mod;
		}
	}
	cout << (dp[vec.size() - 1][1] - dp[vec.size() - 1][0] + mod) % mod << endl;
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define task "B"
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))

#define y1 wtf_

const int N=200010;

int m,n,q,x1,y1;
string s,t;
map<char,char> rev;


int shift(int &x,int &y,char ch)
{
    x+=ch == 'U' ? -1 : ch=='D' ? 1 : 0;
    y+=ch == 'L' ? -1 : ch=='R' ? 1 : 0;

}


int F(char ch)
{
    int x,y; x=x1, y=y1;
    forinc(i,0,q-1)
    {
        if(s[i]==ch) shift(x,y,ch);
        if(ch=='L' && y<1) return 1;
        if(ch=='R' && y>n) return 1;
        if(ch=='U' && x<1) return 1;
        if(ch=='D' && x>m) return 1;
        if(t[i]==rev[ch]) shift(x,y,rev[ch]);
        x=max(1,min(x,m));
        y=max(1,min(y,n));
    }
    return 0;
}

main()
{
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    fasty;
    cin>>m>>n>>q;
    cin>>x1>>y1;
    cin>>s;
    cin>>t;

    rev['L']='R';
    rev['R']='L';
    rev['U']='D';
    rev['D']='U';

    string moves="LRUD";
    int ret=1;
    forinc(i,0,3) ret=ret && !F(moves[i]);
    cout<<(ret ? "YES" : "NO");
}


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

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

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define DEBUG(x) std::cerr << #x << " : " << (x) << std::endl;
//#define DEBUG(x) ;

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

int main(int argc, char **argv)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll h, w; cin >> h >> w;
	ll n; cin >> n;
	ll cnt{0};
	ll m = max(h, w);

	while (true)
	{
		n -= m;
		++cnt;

		if (n <= 0) break;
	}

	std::cout << cnt << std::endl;
	
	return 0;
}


Measured memory_bytes: 3640
n,k=map(int, input().split())
A = list(map(int, input().split()))
A=[i-1 for i in A]
order=[-1]*n
order[0]=0
now=0
cnt=0
loop=-1
while True:
    now=A[now]
    cnt+=1
    if order[now]==-1:
        order[now]=cnt
    else:
        loop=now
        break

neworder=[]
for i in range(n):
    if i==loop:
        loop=[order[i],i]
    if order[i]!=-1:
        neworder.append([order[i],i])


neworder=sorted(neworder)
#print(neworder)
if k<=loop[0]:
    print(neworder[k%len(neworder)][1]+1)
else:
    k-=loop[0]
    neworder=neworder[loop[0]:]
    print(neworder[k%len(neworder)][1]+1)

Measured memory_bytes: 111648
#include <stdio.h>

int main(void)
{
  int n, r;
  scanf("%d %d", &n, &r);
  
  int ans = 0;
  if (n >= 10)
  {
    ans = r;
  }
  else if (n < 10)
  {
    ans = r + (100 * (10 - n));
  }
  printf("%d", ans);
  return 0;
}


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

int main(){
  int S;
  cin >> S;

  int h, m, s;

  h = S / 3600;
  S -= h*3600;

  m = S / 60;
  S -= m*60;

  s = S;

  cout << h << ":" << m << ":" << s << endl;
  return 0;

}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int N;cin>>N;cout<<N*N*N<<endl;
}


Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1e9 + 7;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, bool isFront) {
	if (first_itr < 0 || first_itr > str.size()) {
		return str;
	}
	else {
		if (isFront) {
			std::string tmp;
			for (size_t i = 0; i < first_itr; i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
		else {
			std::string tmp;
			for (size_t i = first_itr; i < str.size(); i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
	}
}


bool dfs(int depth, str s) {
	/*if (depth == n) {
		ans.push_back(s);
		return false;
	}
	for (int i = 0; i < n; i++) {
		if (dfs(depth + 1, s + dic.at(i))) {
			return true;
		}
	}*/
	return false;
}


int main() {
	int n; cin >> n;
	priority_queue<double,vecd,std::greater<>> q;
	rep(i, n) {
		double tmp; cin >> tmp;
		q.push(tmp);
	}
	while (!q.empty()) {
		double x = q.top();
		q.pop();
		if (q.empty()) {
			cout << x << endl;
			return 0;
		}
		double y = q.top();
		q.pop();
		double res = (x + y) / 2;
		q.push(res);
	}
	cout << q.top() << endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 300
#define MOD 1000000007
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int k,n;
	cin>>k>>n;
	vector<int> v(n);
	for(int i=0;i<n;++i)	
		cin>>v[i];
	int ans = INT_MAX;
	for(int i=0;i<n;++i)
	{
		int dist = v[n-1]-v[i];
		if(i)
			dist += k-v[n-1]+v[i-1];
		ans = min(ans,dist);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
   llong n,h[102];
   cin >> n;
   rep(i,n) cin >> h[i];
   
   llong ans = h[0];
   rep(i,n-1){
       if(h[i+1] >= h[i]) ans += h[i+1]-h[i];
   }
   
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
clock_t __my_start_clock = clock();
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, (clock() - __my_start_clock)*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

int main() {
#ifdef LOCAL
  freopen("a.in", "r", stdin);
  freopen("a.out", "w", stdout);
#endif

  int n;
  while (scanf("%d", &n) == 1) {
    int val = -1;
    int cnt = 0;
    int ans = 0;
    for (int i = 0; i < n; i++) {
      int x;
      scanf("%d", &x);
      if (x == val) {
        cnt++;
      } else {
        val = x;
        ans += cnt / 2;
        cnt = 1;
      }
    }
    ans += cnt / 2;
    printf("%d\n", ans);
  }

  return 0;
}


Measured memory_bytes: 256
a = int(input())
b = input().split()
for i in range(a):
  b[i] = int(b[i])
  
for i in range(a-1):
  if (b[i] > b[i+1]):
    break
if i == a-2:
  print('YES')
else:
  for j in range(a-1,i,-1):
    if (b[j] < b[j-1]):
      break
  temp = b[i]
  b[i] = b[j]
  b[j] = temp
  for k in range(a-1):
    if (b[k] > b[k+1]):
      break
  if k == a-2:
    print('YES')
  else:
    print('NO')

Measured memory_bytes: 3064
InputData=[]
while True:
    try:
        in1,in2 = map(int,raw_input().split(" "))  # Python2
        if in1==0 and in2==0 : break
        InputData.append([in1,in2])
    except EOFError:
        break

for i in range(len(InputData)):
    in1,in2 = InputData[i]
    x = int(in1) * int(in2)
    y = int(in1) + int(in2) + int(in1) + int(in2)
    print(str(x) + " " + str(y))

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

int main(){
  ll n;  cin >> n ;
  int a[n],b[n-1];
  ll all=0;
  rep(i,n-1){
     cin >> b[i];
  }
  all += b[0];
  all += b[n-2];
  for(int i=1;i<=n-2;i++){
     all += min(b[i-1],b[i]);
  }
  
  cout << all << endl;
}



Measured memory_bytes: 256
S = input()
r,l=0,0
pr = 0
OS=[0 for i in range ( len(S))]
for i in range (len(S)):
  if S[i] == 'R':
    if l > 0:
      OS[n-1] = (r+1)//2 + l//2
      OS[n] = r//2 + (l+1)//2
      r = 0
    l = 0
    r+=1
    pr = 1
  else:
    l+=1
    if pr == 1:
      n = i
      pr = 0
OS[n-1] = (r+1)//2 + l//2
OS[n] = r//2 + (l+1)//2
for i in range(len(OS)):
  print(OS[i], end=" ")

    



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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define all(v) v.begin(), v.end()
#define PB push_back
#define F first
#define S second

typedef unsigned long long llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int INF = 1e9+10;
const ll MOD = 1e9+7;

ll dp[101][101][2];

ll solve(string& num, int pos, int sum, int f, int k){
	if(pos == (int) num.size())
		return sum == k;
	if(dp[pos][sum][f] != -1)
		return dp[pos][sum][f];
	if(sum > k)
		return dp[pos][sum][f] = 0;
	int mx = (f ? 9 : num[pos]-'0');
	int ret = 0;
	for(int i = 0; i < mx; i++)
		ret += solve(num, pos+1, sum + (i>0), 1, k);
	ret += solve(num, pos+1, sum + (mx>0), f, k);
	return dp[pos][sum][f] = ret;
}


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

	string n;
	int k;
	cin >> n >> k;

	memset(dp, -1, sizeof dp);
	cout << solve(n, 0, 0, 0, k) << '\n';

	return 0;
}

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

using namespace std;

int main() {
  int n; cin >> n;

  vector<int> b(n-1);
  for (int i = 0; i < n-1; i++) {
    cin >> b[i];
  }

  int ans = b[0] + b[n-2];
  for (int i = 0; i < n-2; i++) {
    ans += min(b[i], b[i+1]);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define Fast  ios::sync_with_stdio(false); cin.tie(0)
#define pb push_back
#define pf push_front
#define pp pop
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define S second
#define F first
typedef long long ll;
const ll mod = 1e9 + 7;
const ll N = 1e6 + 5;
ll inf = 1e18;

int main(){

    ll n;
    cin >> n;

    ll ans = 1;
    ll tmp = 1;
    ll tm = 1;

    while(n --){
        ans *= 10;
        tmp *= 9;
        tm *= 8;
        ans %= mod;
        tmp %= mod;
        tm %= mod;
    }
    tmp *= 2;
    tmp %= mod;
    ans -= tmp;
    ans %= mod;
    ans += tm;
    ans %= mod;

    if(ans < 0)ans += mod;

    cout << ans;

    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define maxs 202
#define mme(i,j) memset(i,j,sizeof(i))
using namespace std;
int flag[maxs];
int s[20] = {1,400,800,1200,1600,2000,2400,2800,3200,4900};

int main()
{
    int n,m;
    while(~scanf("%d",&n)){
        mme(flag,0);
        int x;

        for(int i=1;i<=n;i++){
            scanf("%d",&x);
            for(int j=0;j<9;j++){
                if(x>=s[j]&&x<s[j+1]){
                    flag[j]++;
                    break;
                }
            }
        }

        int re=0;
        for(int i=0;i<8;i++)
            if(flag[i]>0) re++;

        if(!re)
            printf("%d  %d\n",1,flag[8]);
        else
            printf("%d %d\n",re,re+flag[8]);

    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int sz=2e6+9;
string arr[]={"SUN", "MON", "TUE", "WED", "THU", "FRI","SAT"};

int main(){
	string s;
	cin>>s;
	for(int i=0;i<7;i++){
		if(s==arr[i]){
			int cnt=1;
			int j=i+1;
			if(j==7) j=0;
			while(arr[j]!="SUN"){
				j++;
				if(j==7) j=0;
				cnt++;
			}
			cout<<cnt;
			return 0;
		}
	}

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a,b,c,d;
  scanf("%d %d %d",&a,&b,&c);
  d=a;
  a=b;
  b=d;
  d=a;
  a=c;
  c=d;
  printf("%d %d %d",a,b,c);
  
  return 0;
}

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

vector<int> arr;

int main( void ) {
    
    int n;
    cin >> n;
    
    for( int i = 1; i <= n; n -= i ++ )
        arr.push_back( i );

    reverse( arr.begin(), arr.end() );
    for( int i = 0; i < n; i ++ )
        arr[i] ++;
    
    reverse( arr.begin(), arr.end() );
    for( int i = 0; i < arr.size(); i ++ )
        cout << arr[i] << '\n';
    
    return 0;
}


Measured memory_bytes: 384
from copy import deepcopy
def resolve():
    N = int(input())
    A = list(map(int,input().split()))
    tbl = dict()
    tbl[0]= 1000
    for i in A:
        ntbl = deepcopy(tbl)
        for kabu,yen in tbl.items():
            ny = yen + kabu * i
            nk = 0
            if not nk in ntbl or ntbl[nk]<ny:
                ntbl[nk]=ny

            nk = yen // i + kabu
            ny = yen % i
            if not nk in ntbl or ntbl[nk]<ny:
                ntbl[nk]=ny
        tbl = ntbl
    print(max(tbl.values()))    
    

resolve()



Measured memory_bytes: 68948
#pragma warning(disable: 4996)
#define _USE_MATH_DEFINES
#include <iostream>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <bitset>
using namespace std;

int isprime(long long x) {
	int a = 1;
	long long i;
	long double root_x;
	if (x == 2) {
		a = 1;
	}
	else if (x < 2 or x % 2 == 0) {
		a = 0;
	}

	i = 3;
	root_x = pow(x, 0.5);
	while (i <= root_x) {
		if (x % i == 0) {
			a = 0;
		}
		i = i + 2;
	}
	return a;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long N;
	cin >> N;
	long double M = N;
	if (isprime(N)) cout << N - 1 << endl;
	else {
		long double root_N;
		root_N = pow(N, 0.5);
		long long min_dif = 10000000, ans = 1000000000000;

		for (long long i = 2; i <= root_N; i++) {
			if (floor(M / i) == M / i) {
				min_dif = min(abs(N / i - i), min_dif);
				ans = min(ans, (i + (N / i) - 2));
			}
		}
		cout << ans << endl;
	}
	

	return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
  input! {
    n: usize,
    av: [i64; n]
  };

  let inf = 1_i64 << 60;
  let m = n / 2;
  let mut dp = vec![std::collections::HashMap::new(); n + 1];
  dp[0].insert(0, vec![0; 3]);
  for i in 0..n {
    let r = (i + 1) / 2;
    let l = if r > 0 { r - 1 } else { 0 };
    for j in l..=r {
      // select
      if j + 1 <= m {
        let mut x = if let Some(x) = dp[i + 1].get(&(j + 1)) {
          x.clone()
        } else {
          vec![-inf; 3]
        };
        x[0] = vec![
          x[0],
          dp[i].get(&j).unwrap()[1] + av[i],
          dp[i].get(&j).unwrap()[2] + av[i],
        ]
        .into_iter()
        .max()
        .unwrap();
        dp[i + 1].insert(j + 1, x);
      }
      // not select
      let mut x = if let Some(x) = dp[i + 1].get(&j) {
        x.clone()
      } else {
        vec![-inf; 3]
      };
      x[1] = vec![x[1], dp[i].get(&j).unwrap()[0]]
        .into_iter()
        .max()
        .unwrap();
      x[2] = vec![x[2], dp[i].get(&j).unwrap()[1]]
        .into_iter()
        .max()
        .unwrap();
      dp[i + 1].insert(j, x);
    }
  }
  println!(
    "{}",
    dp[n].get(&m).unwrap().clone().into_iter().max().unwrap()
  );
}


Measured memory_bytes: 66616
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
//const int mod = 1e9+7;
const ll mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int ninf = 0xc0c0c0c0; ll n,k;
ll func(ll x){
	 
	return (2*n-x+1)*x/2 - (x-1)*x/2 + 1;
}
int main(){
	//freopen("in.txt","r",stdin);
	
	cin>>n>>k;
	ll sum=0;
	for(ll i=k;i<=n+1;i++){
		sum=(sum+func(i))%mod;
	}
	
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int dp[100001];
int func(int arr[], int n, int prv){
    if(prv==n-1){
        return 0;
   }
   if(prv==n-2){
        return abs(arr[prv]-arr[prv+1]);
        }
  if(dp[prv]!=-1)
    return dp[prv];
    int ans1=0,ans2=0;
    ans1+=abs(arr[prv]-arr[prv+1])+func(arr,n,prv+1);
    ans2+=abs(arr[prv]-arr[prv+2])+func(arr,n,prv+2);
    dp[prv]=min(ans1,ans2);
    return min(ans1,ans2);
}
int main(){
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    memset(dp,-1,sizeof(dp));
    cout<<func(arr,n,0);
    return 0;
}


Measured memory_bytes: 12168
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;
long long int solve(long long int a, long long int b) {
	long long int c = a % b;
	if (c == 0)return b;
	return solve(b, c);
}
int main() {
	long long int a;
	long long int b;
	cin >> a;
	cin >> b;
	if (a < b) {
		long long int y = a;
		a = b;
		b = y;
	}
	long long int y = solve(a, b);
	long long int ans = 1;
	long long int cnt = 2;
	
	
	for (int i = 2; i < sqrt(y); i++) {
		if (y % cnt == 0)ans++;
		else {
			cnt++;
			continue;
		}
		while (y % cnt == 0) {
			y = y / cnt;
		}
		cnt++;
	}
	if (y != 1)ans++;
	cout << ans;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:

};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    string s;
    cin >> s;
    string t = "ABC";

    int res = 0;
    for (int i = 0; i + t.length() <= n; ++i) {
        if (s.substr(i, t.length()) == t) {
            ++res;
        }
    }

    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n;i++)
int main(void) {
	int n, sum = 0,ma = 0, nx = 0,a,u;
	cin >> n;
	rep(i, n) {
		cin >> a;
		if (ma < a) {
			nx = ma;
			ma = a;u = i;
		}
		else if (ma == a) {
			nx = a; ma = a;
		}
		if (ma > a&& nx < a) {
			nx = a;
		}
	}
	rep(i, n) {
		if (ma == nx || u !=i) {
			cout << ma << endl;
		}
		else  {
			cout << nx << endl;
		}
	}
}

Measured memory_bytes: 1664
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Printer pr = new Printer(System.out);

		char[] s = sc.next().toCharArray();
		int n = s.length;

		for (int i = 1; i < n; i++) {
			if (s[i] == s[i - 1]) {
				pr.printf("%d %d\n", i, i + 1);

				pr.close();
				sc.close();
				return;
			}
		}

		for (int i = 2; i < n; i++) {
			if (s[i] == s[i - 2]) {
				pr.printf("%d %d\n", i - 1, i + 1);

				pr.close();
				sc.close();
				return;
			}
		}

		pr.printf("%d %d\n", -1, -1);

		pr.close();
		sc.close();
	}

	@SuppressWarnings("unused")
	private static class Scanner {
		BufferedReader br;
		Iterator<String> it;

		Scanner (InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}

		String next() throws RuntimeException  {
			try {
				if (it == null || !it.hasNext()) {
//					it = Arrays.asList(br.readLine().split(" ")).iterator();
					it = Arrays.asList(br.readLine().split("\\p{javaWhitespace}+")).iterator();
				}
				return it.next();
			} catch (IOException e) {
				throw new IllegalStateException();
			}
		}

		int nextInt() throws RuntimeException {
			return Integer.parseInt(next());
		}

		long nextLong() throws RuntimeException {
			return Long.parseLong(next());
		}

		float nextFloat() throws RuntimeException {
			return Float.parseFloat(next());
		}

		double nextDouble() throws RuntimeException {
			return Double.parseDouble(next());
		}

		void close() {
			try {
				br.close();
			} catch (IOException e) {
//				throw new IllegalStateException();
			}
		}
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 11348
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

class Main {

    public static void main( final String[] args ) {

	final Scanner stdin = new Scanner( System.in );
	
	final HashSet<Character> left = new HashSet<Character>();
	for ( final char ch : "qwertasdfgzxcvb".toCharArray() ){
	    left.add( ch );
	}

	final int LEFT = 0;
	final int RIGHT = 1;
	
	while ( true ) {

	    final String input = stdin.nextLine();
	    if ( "#".equals( input ) ) {
		break;
	    }

	    int hand = -1;
	    int count = 0;
	    for ( final char ch : input.toCharArray() ) {
		final int curHand = ( left.contains( ch ) ? LEFT : RIGHT );
		if ( hand != curHand ) {
		    if ( hand != -1 ) {
			count++;
		    }
		    hand = curHand;
		}
	    }
	    System.out.println( count );
	}	
    }    
}

Measured memory_bytes: 17868
k,x = map(int,input().split())
big = x+k-1
small = x-k+1
if small < -1000000:
  for i in range in(-1000000,big+1):
    print(i,"",end='')
elif big > 1000000:
  for i in range in (small,1000000+1):
    print(i,"",end='')
if small >= -1000000 and big <= 1000000:
  for i in range(small,big+1):
    print(i,"",end='')

Measured memory_bytes: 3064