akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
    int n,i=0;
    char str[10001];
    scanf("%d", &n);
    scanf("%s", str);
    if(n>0)
    {
         while(str[i]!='\0')
    {
        if(str[i]+n>='A' && str[i]+n<='Z')
        {
             str[i]=str[i]+n;
        }
       else
       {
           str[i]=str[i]-26+n;
       }
        i++;
    }
    str[i]='\0';
    }

    printf("%s\n", str);
    return 0;
}


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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for(auto& x : s)
        cin >> x;
    vector<int> a(h, 0), b(w, 0);
    for(int i = 0; i < h; ++i)
        for(int j = 0; j < w; ++j){
            a[i] += (s[i][j] == '#');
            b[j] += (s[i][j] == '#');
        }
    for(int i = 0; i < h; ++i){
        if(!a[i])
            continue;
        for(int j = 0; j < w; ++j){
            if(!b[j])
                continue;
            cout << s[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
/*
 * @Filename: 
 * @Author: shifaqiang
 * @Email: 14061115@buaa.edu.cn
 * @Github: https://github.com/luoboganer
 * @Date: 2020-07-12 00:38:24
 * @LastEditors: shifaqiang
 * @LastEditTime: 2020-07-13 15:54:41
 * @Software: Visual Studio Code
 * @Description: 
 */

#include <algorithm>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
    int h, w, mod = 1e9 + 7;
    cin >> h >> w;
    vector<string> grid(h);
    for (int i = 0; i < h; ++i)
    {
        cin >> grid[i];
    }
    vector<vector<int>> dp(h, vector<int>(w, 0));
    for (int i = 0; i < h; ++i)
    {
        if (grid[i][0] == '.')
        {
            dp[i][0] = 1;
        }
        else
        {
            break;
        }
    }
    for (auto j = 0; j < w; j++)
    {
        if (grid[0][j] == '.')
        {
            dp[0][j] = 1;
        }
        else
        {
            break;
        }
    }
    for (int i = 1; i < h; ++i)
    {
        for (int j = 1; j < w; j++)
        {
            if (grid[i][j] == '.')
            {
                dp[i][j] = ((long long)dp[i - 1][j] + dp[i][j - 1]) % mod;
            }
        }
    }
    cout << dp[h - 1][w - 1] << endl;
    return 0;
}

Measured memory_bytes: 9464
#include<vector>
#include<iostream>
#include<algorithm>
#include<tuple>
#include<string>
#include<bits/stdc++.h>
using namespace std;

string str;
void solve(){
   int N;
   bool l,r;
   l=false,r=false;
   int ans=0;

    cin>>N>>str;

    for(int i=1;i<N;i++){
        int cnt=0;
        for(char c='a';c<='z';c++){
            l=false,r=false;
            for(int g=0;g<i;g++){
               if( str[g]==c)l=true;
            }
            for(int j=i;j<=N;j++){
                if(str[j]==c)r=true;
            }
            if((l==true)&&(r==true))cnt++;
        }
        ans=max(ans,cnt);
    }

    
    cout<<ans<<endl;
}

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

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

using namespace std;

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

	vector<int> k;
	vector<int> a;
	vector<int> f(m);
	for (int i = 0; i < n; i++)
	{
		int tmp_k;
		cin >> tmp_k;
		k.push_back(tmp_k);
		for (int j = 0; j < k.at(i); j++)
		{
			int tmp_a;
			cin >> tmp_a;
			a.push_back(tmp_a);
			f.at(tmp_a - 1)++;
		}
	}

	int count = 0;
	for (int i = 0; i < m; i++)
	{
		if (f.at(i) == n)
		{
			count++;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
long bignum = 1_000_000_007;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long n, m;
    scan(n, m);
    abs((n - 2) * (m - 2)).writeln();
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;

//_____________________________________________________________
#define MAX_NODE 1000000

struct tree{
  int number;
  std::vector<int> c;
  std::vector<int> child;
  int t = -1;
};

std::vector<tree> T(MAX_NODE+1);
std::vector<int> check_init(MAX_NODE+1,0);
vvl load = vv(501, 501, 1, ll);
std::vector<int> cheked(505, 0);
void dfs(int num, int level, ll time, ll prev){
  T[num].t = time;
  cheked[num] = 1;
  for(int i=0;i<T[num].child.size();i++) {
    if(T[num].child[i]==prev) continue;
    if(level==load[num][T[num].child[i]]) {
      if(T[T[num].child[i]].t!=-1) {
        if(abs(time+1-T[T[num].child[i]].t)%2==0) continue;
        load[num][T[num].child[i]]++;
        load[T[num].child[i]][num]++;
      }else dfs(T[num].child[i], load[num][T[num].child[i]], time+1, num);
    }
  }
}
void tree_init(){
  for(int i=1;i<=MAX_NODE;i++) T[i].number=i;
}

void print_load(int N){
  for(int i=1;i<=N-1;i++){
    for(int j=i+1;j<=N;j++) std::cout << load[i][j]  << " ";
    std::cout << '\n';
  }
}
//_____________________________________________________________

int main(int argc, char const *argv[]) {
  ll N;
  std::cin >> N;
  for(int i=1;i<=N;i++){
    for(int j=i+1;j<=N;j++){
      if(i==j) continue;
      T[i].child.push_back(j);
      T[j].child.push_back(i);
    }
  }
  tree_init();
  for(int i=1;i<=N;i++){
    for(int k=1;k<=N;k++) cheked[k]=0;
    for(int k=1;k<=N;k++){
      if(cheked[k]==1) continue; 
      for(int j=1;j<=N;j++) T[j].t=-1;
      dfs(k, i, 0, -1);
    }
  }
  print_load(N);
  return 0;
}


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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int GCD(int a,int b){return b?GCD(b,a%b):a;}
long long GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int LCM(int a, int b){return a * b / GCD(a, b);}
long long LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
const int INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const double EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right

//#define int long long

//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



signed main()
{
	int n,a,b; cin >> n>>a>>b;
	//min(a*n,b);
	cout << min(a*n,b);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

int main() {
    vector<int> A={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin>>K;
    cout << A[K-1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

ll N, L;
double t[512345];
ll v[512345];

int main() {
	cin >> N >> L;
	REP(i, N) scanf("%lf %lld", t + i, v + i);
	
	deque<pair<double, ll> > deq;
	double sump = 0, sumv = 0;
	
	REP(i, N) {
		sump += t[i] * v[i];
		sumv += v[i];
		
		while (!deq.empty() && deq.back().fi > t[i]) {
			double tt = deq.back().fi;
			ll vv = deq.back().se;
			
			t[i] = (tt * vv + t[i] * v[i]) / (vv + v[i]);
			v[i] = vv + v[i];
			deq.pop_back();
		}
		deq.push_back(make_pair(t[i], v[i]));
		
		printf("%.15lf\n", sump / L);
		
		if (i < N - 1) {
			ll diff = v[i + 1] + sumv - L;
			while (!deq.empty() && diff > 0) {
				double tt = deq.front().fi;
				ll vv = deq.front().se;
				deq.pop_front();
				
				if (diff < vv) {
					vv -= diff;
					sump -= diff * tt;
					sumv -= diff;
					deq.push_front(make_pair(tt, vv));
					diff = 0;
				}
				else {
					sump -= vv * tt;
					sumv -= vv;
					diff -= vv;
				}
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 29072
#include<bits/stdc++.h>
using namespace std; //std::の省略のため
using ll = long long;

int main(){
    int a,b,c,x;

    cin >> a >> b >> c >> x;

    int sum;
    int count = 0;

    for(int i = 0; i <= a; i++){
        for(int j = 0; j <= b; j++){
            sum = 500*i + 100*j;
            if(sum > x) break;
            for(int k = 0; k <= c; k++){
                sum = 500*i + 100*j + 50*k;
                if(sum > x) {
                    break;
                }
                if(sum == x) count++;
            }
            
        }
    }

    cout << count << endl;
}

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


int main() {
	int N, Q;
	cin >> N >> Q;
	string s;
  	cin >> s;
	vector<int> cnt(N);
	for(int i=0;i<N-1;i++) {
      	cnt[i+1] = cnt[i];
		if (s.at(i) == 'A' && s.at(i + 1) == 'C') cnt[i+1]++;
	}
	vector<int> ans(Q);
	rep(i, Q) {
		int l, r;
		cin >> l >> r;
		l--; r--;
		ans[i] = cnt[r] - cnt[l];
	}
	rep(i, Q) cout << ans[i] << endl; 
}





Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define mod 1000000007
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=(a*a)%mod;
		b>>=1;
	}
	return ans;
}

void dfs(set<int>& s,vector<int> v[],bool vis[],int i){
	vis[i]=true;
	s.insert(i);
	for(auto j:v[i]){
		if(vis[j]==false)
		dfs(s,v,vis,j);
	}
}


int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		int n,m,k;
		cin>>n>>m>>k;
		vector<int> v[n+1],block[n+1];
		int p,q;
		for(int i=0;i<m;i++){
			cin>>p>>q;
			v[p].push_back(q);
			v[q].push_back(p);
		}
		for(int i=0;i<k;i++){
			cin>>p>>q;
			block[p].push_back(q);
			block[q].push_back(p);
		}
		bool vis[n+1];
		memset(vis,false,sizeof(vis));
		int ans[n+1];
		memset(ans,0,sizeof(ans));
		for(int i=1;i<=n;i++){
			if(vis[i]==false){
				set<int> s;
				dfs(s,v,vis,i);
				int z=s.size();
				for(auto j:s){
					z--;
					if(block[j].size()!=0)
					for(auto l:block[j]){
						if(s.count(l))
						z--;
					}
					ans[j]=z-v[j].size();
					z=s.size();
				}
			}
		}
		for(int i=1;i<=n;i++)
		cout<<ans[i]<<" ";
	}
	return 0;
}

Measured memory_bytes: 17016
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main() {
	int a;
	string s;
	cin >> a >>s;
	if (a >= 3200)cout << s << endl;
	else cout << "red" << endl;


	return 0;
}

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

a.sort()
if x == sum(a):
    print(n)
elif x > sum(a):
    print(n-1)
else:
    for i in range(n):
        if x < a[i]:
            print(i)
            break
        x -= a[i]
        

Measured memory_bytes: 3060
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <cfenv>
#include <cinttypes>
#include <cstdint>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <forward_list>
#include <initializer_list>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#if __cplusplus >= 201402L
#include <shared_mutex>
#endif

#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;

const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};



int main(){
 
    int n;
    cin >> n;
    vector<char> c(n);
    int r = 0;
    int w = 0;
    rep(i,n){
        cin >> c[i];
        if(c[i] == 'R') r++;
        else w++;
    }
    int ans = 0;
    int t = 0;
    int tr = 0;
    int tw = 0;
    rep(i,r){
        if(c[i] == 'W') tw++;
    }
    for(int i = n-1;i > n-1-w;--i){
        if(c[i] == 'R') tr++;
    }
    ans = min(tr,tw);
    ans = min(ans,min(r,w));

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


Measured memory_bytes: 3156
// abc121_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int H, W;
    cin >> H >> W;
    int h, w;
    cin >> h >> w;

    int ans = H * W - (h * w) - (H - h) * w - h * (W - w);
    print(ans);

    return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;

#define fr first
#define sc second

int main(){
	int n,k;
	string s;
	cin >> n >> k >> s;
	
	vector<int> vec;
	vec.push_back(0);
	int now = 1;
	for(int i = 0 ; i < n ; i ++){
		if(s[i]-'0' != now){
			vec.push_back(i);
			now = 1-now;
		}
	}
	for(int i = 0 ; i < 2*k+1 ; i ++)vec.push_back(n);
	
	int ret = 0;
	for(int i = 0 ; i+2*k+1 < vec.size() ; i += 2){
		ret = max( ret , vec[i+2*k+1]-vec[i] );
	}
	cout << ret << endl;
}

Measured memory_bytes: 1528
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
 
void insert(int);
void preorder(Node);
void inorder(Node);
 
#define NIL NULL
 
Node root;
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
     while (x != NIL){
         y = x;
         if (z->key < x->key)
             x = x->left;
         else
             x = x->right;
             z->parent = y;
}
    if (y == NIL)
        root = z;
    else if (z->key < y->key)
        y->left = z;
    else
        y->right = z;
 
}
 
void inorder(Node u){
if (u == NIL) return;
inorder(u->left);
printf(" %d", u->key);
inorder(u->right);
}
 
void preorder(Node u){
    if(u == NIL) return;
    printf(" %d", u->key);
preorder(u->left);
preorder(u->right);
}
 
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
   
  for ( i = 0; i < n; i++ ){
      scanf("%s", com);
      if(com[0] == 'i'){
          scanf("%d", &x);
      insert(x);
      }
      else if(com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
}
}
  return 0;
}



Measured memory_bytes: 25140
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
template <typename T,typename E>
struct SegmentTree{
  typedef function<T(T,T)> F;
  typedef function<T(T,E)> G;
  typedef function<E(E,E)> H;
  typedef function<E(E,int)> P;
  int n;
  F f;
  G g;
  H h;
  P p;
  T d1;
  E d0;
  vector<T> dat;
  vector<E> laz;
  SegmentTree(int n_,F f,G g,H h,T d1,E d0,
	      vector<T> v=vector<T>(),P p=[](E a,int b){return a;}){
    this->f=f;
    this->g=g;
    this->h=h;
    this->p=p;
    this->d1=d1;
    this->d0=d0;
    init(n_);
    if(n_==(int)v.size()) build(n_,v);
  }
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,d1);
    laz.clear();
    laz.resize(2*n-1,d0);
  }
  void build(int n_, vector<T> v){
    for(int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  inline void eval(int len,int k){
    if(k*2+1<n*2-1){
      laz[k*2+1]=h(laz[k*2+1],laz[k]);
      laz[k*2+2]=h(laz[k*2+2],laz[k]);
    }
    dat[k]=g(dat[k],p(laz[k],len));
    laz[k]=d0;
  }
  T update(int a,int b,E x,int k,int l,int r){
    eval(r-l,k);
    if(r<=a||b<=l) return g(dat[k],p(laz[k],r-l));
    if(a<=l&&r<=b){
      laz[k]=h(laz[k],x);
      return g(dat[k],p(laz[k],r-l));
    }
    return dat[k]=f(update(a,b,x,k*2+1,l,(l+r)/2),
		    update(a,b,x,k*2+2,(l+r)/2,r));
  }
  T update(int a,int b,E x){
    return update(a,b,x,0,0,n);
  }
  T query(int a,int b,int k,int l,int r){
    eval(r-l,k);
    if(r<=a||b<=l) return d1;
    if(a<=l&&r<=b) return dat[k];
    T vl=query(a,b,k*2+1,l,(l+r)/2);
    T vr=query(a,b,k*2+2,(l+r)/2,r);
    return f(vl,vr);
  }
  T query(int a,int b){
    return query(a,b,0,0,n);
  }
};
//END CUT HERE
signed main(){
  int n,q;
  cin>>n>>q;
  SegmentTree<Int,Int> ch(n,
			  [](Int a,Int b){return a+b;},
			  [](Int a,Int b){return a+b;},
			  [](Int a,Int b){return a+b;},
			  0,0,vector<Int>(n,0),
			  [](Int a,int b){return a*b;});
  for(int i=0;i<q;i++){
    int c,s,t,x;
    cin>>c;
    if(c){
      cin>>s>>t;
      cout<<ch.query(s-1,t)<<endl;
    }else{
      cin>>s>>t>>x;
      ch.update(s-1,t,x);
    }
  }
}

/*
verified on 2017/10/15
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_G
*/

Measured memory_bytes: 8432
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <vector>

using namespace std;
typedef long long LL;
const int maxn = 20005;

int A,B,stk[maxn],top,p[maxn];char s[maxn];
int main()
{
	#ifdef Amberframe
		freopen("arc070f.in","r",stdin);
		freopen("arc070f.out","w",stdout);
	#endif
	scanf("%d %d",&A,&B);
	if (A<=B) {
		puts("Impossible");
		fflush(stdout);
		return 0;
	}
	for (int i=0;i<A+B;i++)
	{
		if (top) {
			printf("? %d %d\n",i,stk[top]);
			fflush(stdout);
			scanf("%s",s);
			*s=='Y'?stk[++top]=i:--top;
		}
		else stk[++top]=i;
	}
	int o=stk[1];
	for (int i=0;i<A+B;i++)
	{
		printf("? %d %d\n",o,i);
		fflush(stdout);
		scanf("%s",s);
		p[i]=*s=='Y';
	}
	printf("! ");
	for (int i=0;i<A+B;i++)
		printf("%d",p[i]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 840
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mx *max_element
#define mn *min_element
#define fo(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,n) for(ll i=n-1;i>=0;i--)
#define rloop(i,a,b) for(ll i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define sortall(x) sort(all(x))
#define precision cout<<fixed<<setprecision(10)
#define mem(x,p) memset(x,p,sizeof(x))
#define w(t) ll t;cin>>t;while(t--)
#define kk "\n"
#define setbits(x) __builtin_popcountll(x)
const double pi=3.1415926535897932384626;
//const ll mod = 998244353;
const ll mod=1e9+7;
int main()
{
  IOS
  ll n;
  cin>>n;
  if(n>=30) cout<<"Yes";
  else
  cout<<"No";
  return 0;
}

Measured memory_bytes: 3604
from math import gcd
from functools import reduce
def main():
    N = int(input())
    A = list(map(int, input().split()))

    M = 10**6+1
    mp = [0]*M
    for a in A:
        mp[a] += 1

    pairwise = 1
    for i in range(2,M):
        if sum(mp[i::i])>1:
            pairwise = 0
            break

    if pairwise:
        print('pairwise coprime')
    elif reduce(gcd, A) == 1:
        print('setwise coprime')
    else:
        print('not coprime')

if __name__ == '__main__':
    main()


Measured memory_bytes: 127836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
vector<ll> fac, finv, inv;


int main(){
    int n;  cin >> n;
    vector<ll> a(n);
    REP(i, n)   cin >> a.at(i);
    sort(ALL(a));

    ll res=0;
    REP(i, 61){
        ll cnt0=0, cnt1=0;
        REP(j, n){
            if(a[j]& 1LL<<i) cnt1 += 1;
            else cnt0 += 1;
        }
        ll tmp = (1LL<<i)%MOD;
        res += tmp*(cnt1*cnt0%MOD);
        res %= MOD;
    }
    cout << res << endl;

}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define INF 1000000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(lp, vec.size()) cout << vec[lp] << " "; print(""); 
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;

const int mod = 1000000007;
class mint {
public:
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res /= a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

ll modpow(ll a, ll n){
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

void Main(){
	
	string S;
	cin >> S;
	ll length = S.size();
	rep(i, length) cout << 'x';
		
}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	Main();
	return 0;
	
}





Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> X(M);
  rep(i, M) cin >> X[i];

  int res = M - N;
  if (res <= 0) {
    cout << 0 << endl;
    return 0;
  }

  vector<int> interval(M - 1);
  sort(all(X));
  rep(i, M - 1) { interval[i] = X[i + 1] - X[i]; }
  sort(all(interval));
  int ans = 0;
  rep(i, res) { ans += interval[i]; }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,M;
cin>>N>>M;
if(N>=0&&N<=100&&M>=0&&M<=100&&(N+M)>=2){
cout<<((N*(N-1))/2 + (M*(M-1))/2)<<endl;}

return 0;}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
// cin.eof() 入力個数の問題
int main() {
    string s;
    cin >> s;
    int d[s.size() + 1], y[s.size() + 1];
    d[0] = 0;
    y[s.size()] = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '<') {
            d[i + 1] = d[i] + 1;
        } else {
            d[i + 1] = 0;
        }
        
    }
    for (int i = s.size()-1; i >= 0; i--) {
        if (s[i] == '>') {
            y[i] = y[i+1] + 1;
        } else {
            y[i] = 0;
        }
    }
    /*rep(i,s.size()+1){
        cout<<"d=="<<d[i]<<endl;
        cout<<"y=="<<y[i]<<endl;
    }*/
ll ans=0;
rep(i,s.size()+1){
    ans+=max(d[i],y[i]);
    //cout<<max(d[i],y[i])<<endl;
}
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4740
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

class Node 
{
public:
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k)
{
    Node *y = NIL;
    Node *x = root;
    Node *z;
    z = new Node();
    
    
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while( x != NIL ){
        y = x;
        if (z->key < x->key){
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;
    if ( y == NIL ){
        root = z;
    } else {
        if ( z->key < y->key){
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u)
{
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(Node *u)
{
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main()
{
    int n, x;
    string com;
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        cin >> com;
        if (com == "insert"){
            scanf("%d", &x);
            insert(x);
        } else if ( com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
    
}

Measured memory_bytes: 24688
package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &a[i])
	}

	fmt.Println(solve(n, a))
}

func solve(n int, a []int) int {
	var sum, max int

	for i := 0; i < n; i++ {
		if a[i] < max {
			sum += (max - a[i])
		} else {
			max = a[i]
		}
	}

	return sum
}


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

typedef long long ll;



int main(){
    string s;
    ll res = 0;

    cin >> s;

    for (ll i = 0; i < (1LL << s.size()-1); i++){
        ll sum = 0;
        string t = s;
        int left = 0;
        //cout << bitset<4>(i) << "\t:" ;
        for (int j = 0; j < s.size()-1; j++){
            if (i & (1<<j)){
                //cout << t.substr(0, j-left+1) << ", ";
                sum += stoll(t.substr(0, j - left+1));
                t = t.substr(j-left+1, t.size()-j+left);
                //cout << t <<  ", ";
                left = j+1;
            }
        }
        //cout << t << endl;
        sum += stoll(t);
        res += sum;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
import math
import pprint
import fractions
import collections
import itertools
from decimal import *
A,B=map(str,input().split())
#print(A*B)
getcontext().prec=40
A=int(A)
#print(Decimal(A)*Decimal(B))

A=str(A)
A=list(map(int,A))
b=list(str(B))
B=[0]*3
#print(A,b)
N=len(A)                #Aの桁数
table=[[0 for _ in range(len(A)+1)] for _ in range(10)]
for i in range(1,10):
    career=0
    for j in range(N,0,-1):
        buf=A[j-1]*i+career
        career=buf//10
        table[i][j]=buf%10
    table[i][0]=career
#print(table)
A=list(A)
A.insert(0,0)
A.insert(len(A),0)
A.insert(len(A),0)

#print(A)
ans=[0]*(len(A))
B=[int(b[0]),int(b[2]),int(b[3])]
#print(B)
#print(ans)
for i in range(2,-1,-1):
    piv=B[i]
    buf=[]
    buf = table[piv]
    #print(buf)
    career=0
    for j in range(N,-1,-1):
        num=ans[j+i]+buf[j]+career
        career=num//10
        ans[j+i]=num%10
    #print(ans)
    #input()
ans=map(str,ans)
s="".join(ans)
print(int(s[:len(s)-2]))






Measured memory_bytes: 77080
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	string n;
	cin>>n;
	int sum=0;
	for(int i=0;i<n.length();i++){
		sum+=int(n[i]-'0');
	}
	if(sum%9==0){
	cout<<"Yes\n";
	}else{
	cout<<"No\n";
	}
	return 0;
}



Measured memory_bytes: 3732
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
bool isPrime(int x){
    if(x == 1) return false;
    for(int i = 2; i <= sqrt(x); i++) if(x % i == 0) return false;
    return true;
}
void solve(){
    int x;
    cin >> x;
    while(!isPrime(x)) x++;
    cout << x;
}
int main(){
    speed;
    int t = 1;
    //cin >> t;
    while(t--) solve();
}

Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>

using namespace std;

int keta(int a){
    int count=0;
    while(a!=0){
        a/=10;
        count++;
    }
    return count;
}


int main(){
   map<char,char> b;
   b['A']='T';
   b['T']='A';
   b['C']='G';
   b['G']='C';

   char s;
   cin>>s;
   cout<<b[s]<<endl;

    return 0;
}

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
 
  if (a + b > c + d ) {
    cout << "Left" << endl;
  }
  if (a + b < c + d ) {
    cout << "Right" << endl;
  }
  if (a + b == c + d ){
    cout << "Balanced" << endl;
  }

}

Measured memory_bytes: 256
//AGC Backfront
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  int64_t cnt = 0;
  bool flag = true;
  if(vec.at(0) != 0){
    flag = false;
  }
  for(int i=0; i<N-1; i++){
    if(vec.at(i) + 1 == vec.at(i+1)){
      cnt++;
    }
    else if(vec.at(i) + 1 < vec.at(i+1)){
      flag = false;
      break;
    }
    else{
      cnt += vec.at(i+1);
    }
  }
  if(flag){
    cout << cnt << endl;
  }
  else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 1920
#include<cstdio>
#include<cmath>
#include<algorithm>
 
using namespace std;
 
int h[200000];
int dp[200000];
 
int main()
{
  int n=0,k=0;scanf("%d%d",&n,&k);for(int i=1;i<=n;i++)scanf("%d",&h[i]);
  dp[1]=0;
  for(int i=2;i<=n;i++)
  {
    dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
    for(int j=2;j<=k&&j<i;j++)dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
  }
  printf("%d",dp[n]);return 0;
}

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

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


	string S;
	cin >> S;

	int A = 0;
	int B = 0;

	rep(i, S.size()) {
		if (S[i] == '0') A++;
		else B++;
	}

	co(min(A, B) * 2);
	
	Would you please return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
long long s(long long n) {
	long long res = 0;
	while (n > 0)
	{
		res += n % 10;
		n /= 10;
	}
	return res;
}
double f(long long n) {
	return (double)(n) / s(n);
}
int main() {
	vector<long long> snuke;
	long long base = 1;
	for (int i = 0; i < 15; i++)
	{
		for (int j = 1; j < 150; j++)
		{
			snuke.push_back(base * (j+1) - 1);
		}
		base *= 10;
	}
	sort(snuke.begin(), snuke.end());
	snuke.erase(unique(snuke.begin(), snuke.end()), snuke.end());
	for (int i = 0; i < snuke.size(); i++)
	{
		for (int j = i+1; j < snuke.size(); j++)
		{
			if(f(snuke[i]) > f(snuke[j])) {
				snuke.erase(snuke.begin() + i--);
				break;
			}
		}
	}
	
	long long K; cin >> K;
	for (int i = 0; i < K; i++)
	{
		cout << snuke[i] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	long long n;
	while(1){
		scanf("%lld",&n);
		if(n==0)break;
		long long i;
		long long ans=0;
		long long k=n/2;
		for(i=1;i*i<k;i++){
			ans+=((k-1)/i+1)-(i+1);
		}
		ans=(ans+n/2-1)*2+i;
		ans=(ans+n)*8;
		printf("%lld\n",ans);
	}
	return 0;
}	

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  int A,B;cin>>A>>B;
  string S;cin>>S;
  REP(i,S.size()) {
    if (i==A) {
      if (S[i]!='-') {
        OUT("No");
        return 0;
      }
    } else {
      if (S[i]<'0' || '9'<S[i]) {
        OUT("No");
        return 0;
      }
    }
  }
  OUT("Yes");

  return 0;
}

Measured memory_bytes: 256
#import<iostream>
#import<vector>
#import<algorithm>
using namespace std;typedef pair<int,int>P;typedef vector<P>L;typedef L::iterator I;int U(L&l,I i,I j){int r=i->second>=j->first;if(r){i->second=max(i->second,j->second);l.erase(j);}return r;}void A(L&l,P p){I i=lower_bound(l.begin(),l.end(),p);i=l.insert(i,p);I j;for(;j=i,++j!=l.end()&&U(l,i,j););for(;i!=l.begin()&&(j=i,U(l,--i,j)););}main(){int n,r;for(;cin>>n>>r,r;){L v[10000],h[10000];for(;n--;){int x1,y1,x2,y2,x,y;cin>>x1>>y1>>x2>>y2;for(x=x1;x<x2;x++){A(v[x],P(y1,y2));}for(y=y1;y<y2;y++){A(h[y],P(x1,x2));}}int s=0,c=0;for(int y=0;y<10000;y++){for(I i=h[y].begin();i!=h[y].end();++i)s+=i->second-i->first;c+=h[y].size()+v[y].size();}cout<<s<<endl;if(r==2){cout<<c*2<<endl;}}{int n;for(n=2e6;n--;)getchar();}}

Measured memory_bytes: 1932
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define iterator IT
#define SIZ(V) V.size()
#define FS(a) fixed<<setprecision(a)
using namespace std;
namespace STARTER {
	int MAX(int a,int b) {
		return a>b?a:b;
	}
	int MIN(int a,int b) {
		return a<b?a:b;
	}
	int ABS(int a) {
		return a<0?-a:a;
	}
	int GCD(int a,int b) {
		return !b?a:GCD(b,a%b);
	}
	int LCM(int a,int b) {
		return a/GCD(a,b)*b;
	}
	int QSM(int a,int b,int p) {
		int ret=1;
		while (b) {
			if (b&1)
				ret=ret*a%p;
			a=a*a%p;
			b>>=1;
		}
		return ret;
	}
	int ROUND(double a) {
		return a+0.5;
	}
}
using STARTER::MAX;
using STARTER::MIN;
using STARTER::ABS;
using STARTER::GCD;
using STARTER::LCM;
using STARTER::QSM;
using STARTER::ROUND;
const int maxN=105;
#define int long long
int n,X[maxN],d[maxN][maxN];
signed main() {
	cin>>n;
	for (int i=1;i<=n;i++)
		cin>>X[i];
	for (int i=1;i<=n;i++)
		for (int P=1;P<=100;P++)
			d[i][P]=(X[i]-P)*(X[i]-P);
	int ans=INT_MAX;
	for (int i=1;i<=100;i++) {
		int sum=0;
		for (int j=1;j<=n;j++)
			sum+=d[j][i];
		ans=min(sum,ans);
	}
	cout<<ans<<'\n';
	return 0;
			
}

Measured memory_bytes: 384
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    N = int(readline())
    #l:=名前の長さ
    #まずはlを求める
    l = 1
    while N - 26 ** l > 0:
        N -= 26**l 
        l += 1
    #長さlの名前のうちN番目（Nの値は上のwhileで更新してあるので注意）の名前を求める
    #aからzを0から25に対応させ26進数としてNを表せばその文字列が答えとなっている
    #上位の桁はaで埋めることに注意する
    N -= 1
    ans = ""
    for _ in range(l):
        ans += chr(ord('a')+N%26)
        N //= 26
    print(ans[::-1])
if __name__ == "__main__":
    main()

Measured memory_bytes: 61976
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

ll cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int n;
    
    cin >> n;

    vector<string> s(n);
    rep(i, n){
        cin >> s[i];
    }

    set<string> st;

    rep(i,s.size()){
        st.insert(s[i]);
    }

    cout << st.size() << endl;
}

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

int main(){
  int N;
  cin >> N;
  int c = N;
  int t = 0;
  while(c > 0){
    t = t + c%10;
    c = c / 10;
  }
  if(N%t == 0){
    cout<< "Yes"<<endl;
  }
  else{
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

#define SORT(c) sort((c).begin(),(c).end())
#define DSORT(c, type) sort(ALL(c), greater<type>())

#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SUM(v) accumulate(ALL(v), 0)
#define AVE(v) SUM(v) / (v).size()
// 入力eと同じ値の要素の数
#define COUNT(v, e) count(ALL(v), e)

using namespace std;


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

  int n, k;
  cin >> n >> k;

  cout << n-k+1 << endl;

  return 0;
}

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

int main() {
  	
  int N;
  cin >> N;
  vector<string> s(N);
  for( int i = 0; i < N; i++ ) {
    cin >> s.at(i);
  }
  
  int M;
  cin >> M;
  vector<string> t(M);
  for( int i = 0; i < M; i++ ) {
    cin >> t.at(i);
  }
  
  
  vector<int> count(N);
  
  for ( int i = 0; i < N; i++ ) {
    for( int j = 0; j < N; j ++ ) {
        if (s.at(i) == s.at(j) ) {
          count.at(i)++;
        }
    }
    for ( int j = 0; j < M; j++ ) {
        if (s.at(i) == t.at(j) ) {
          count.at(i)--;
        }
      }
  }
  
  int max = 0;
  for( int i = 0; i < N; i++ ) {
    if( count.at(i) > max ) {
      max = count.at(i);
    }
  }
  
  cout << max << endl;
}

Measured memory_bytes: 3608
from collections import defaultdict
from string import ascii_uppercase
import sys, bisect, math
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N = read_int()[0]

def solve():
    u = N // 100
    l = N % 100
    if u == 0 and l == 0:
        return 'NA'
    if u == 0:
        if l < 13:
            return 'YYMM'
        else: return 'NA'
    if l == 0:
        if u < 13:
            return 'MMYY'
        else: return 'NA'
    if u > 12:
        if l < 13:
            return 'YYMM'
        else: return 'NA'

    if u < 13:
        if l > 12:
            return 'MMYY'
        else: return 'AMBIGUOUS'
    else:
        return 'NA'

if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 4024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <map>
#include <cmath>
#include <queue>
#include <stack>

using namespace std;

static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];


//深さ優先探索を行う
void dfs(int r, int c){

    //スタックを作る
    stack<int> S;

    //スタックに初期頂点を入れる
    S.push(r);

    //color(ID)を初期頂点に代入する
    color[r] = c;


    //スタックが空でない限り行う
    //rと同じIDを入れ続ける
    while(!S.empty()){

        //スタックの一番上を取り出す
        int u = S.top();S.pop();

        //頂点uにつながっている頂点の数だけ繰り返す
        for(int i=0;i<G[u].size();i++){

            //uにつながっている頂点vを取り出す
            int v = G[u][i];

            //もしvがまだIDが決まっていなかったら
            //まだ何も頂点vが触られていなかったら
            //これがないと永遠にループする
            if(color[v] == NIL){

                //color[v]に同じIDを代入する
                color[v] = c;

                //スタックにvを追加する
                S.push(v);
            }
        }
    }
}

// 連結している部分を同じIDにする
void assignColor(){
    int id = 1;

    //どのIDと等しいか初期化する　初期化値はNIL
    for(int i=0;i<n;i++){
        color[i] = NIL;
    }

    //頂点分繰り返す
    for(int u=0;u<n;u++){

        //もし、ある頂点uのIDがまだ決まっていなかったら
        if(color[u] == NIL){

            //深さ優先探索を行う
            dfs(u, id++);
        }
    }
}

int main() {

    int s, t, m, q;

    cin >> n >> m;  //n・・ユーザーの数　　　m・・友達関係の数
    for(int i=0;i<m;i++){
        cin >> s >> t;
        G[s].push_back(t);        //sとtが友人であることを示す
        G[t].push_back(s);
    }

    assignColor();          //連結している部分を同じIDにする

    cin >> q;

    for(int i=0;i<q;i++){
        cin >> s >> t;
        if(color[s] == color[t]){
            cout << "yes" << "\n";
        }else{
            cout << "no" << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 9008
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	
	vector<int> p(n);
	
	for (auto &&e: p)
		cin >> e;
	
	sort(p.begin(), p.end(), greater<int>());
	
	int result = p[0] / 2;
	
	for (int i = 1; i < n; ++i)
		result += p[i];
	
	cout << result << endl;
}

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

typedef long long ll;

struct Range {
  ll l, r;
};

int main() {
  int n;  cin >> n;
  vector<Range> ranges;
  // cerr << "d a r l" << endl;
  ll r = 1, e;
  vector<ll> lr, la;
  for (int d = 0; d <= n; ++d) {
    int a; cin >> a;
    la.push_back(a);
    ll nr = min(r*2, 1LL<<50);
    if (d == 0) nr = 1;
    // cerr << d << " " << a << " " << r << " " << nr << endl;
    if (a > nr) {
      cout << -1 << endl;
      return 0;
    }
    if (d < n) {
      nr -= a;
      r = nr;
      lr.push_back(r);
      // cout << d << " " << r << endl;
    }
    else {
      e = a;
    }
  }
  ll ans = e;
  for (int i = n-1; i >= 0; --i) {
    ll ne = min(e, lr[i])+la[i];
    ans += ne;
    // cout << i << ":" << ne << endl;
    e = ne;
  }
  cout << ans << endl;
}


Measured memory_bytes: 5060
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;


int main()
{
    int n;
    cin >> n;
    
    int arr[n];
    
    cin >> arr[n/2];
    int temp = 1;
    int sing = -1;
    
    for(int i = 0; i < n - 1; ++i)
    {
        
        cin >> arr[n/2 + temp*sing];
        
        sing*=-1;
        if(i%2 == 1)
        {
            temp++;
        }
    }
    
    
    
    if(n%2 == 1)
    {
        for(int i = n-1; i >=0; --i)
        {
            cout << arr[i] << " "; 
        }
    }
    else{
        for(int i = 0; i < n; ++i)
    {
        cout << arr[i] << " "; 
    }
    }
    
    return 0;
}


Measured memory_bytes: 4372