akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        ArrayList<Long[]> li = new ArrayList<Long[]>();
        for(int i = 0; i < 8; i++){
            li.add(new Long[n]);
        }
        /*
        Long[] ppp = new Long[n];
        Long[] ppm = new Long[n];
        Long[] pmp = new Long[n];
        Long[] pmm = new Long[n];
        Long[] mpp = new Long[n];
        Long[] mmp = new Long[n];
        Long[] mpm = new Long[n];
        Long[] mmm = new Long[n];
        */
        for(int i = 0; i < n; i++){
            long a = sc.nextLong();
            long b = sc.nextLong();
            long c = sc.nextLong();
            li.get(0)[i] = a+b+c;
            li.get(1)[i] = a+b-c;
            li.get(2)[i] = a-b+c;
            li.get(3)[i] = a-b-c;
            li.get(4)[i] = -a+b+c;
            li.get(5)[i] = -a-b+c;
            li.get(6)[i] = -a+b-c;
            li.get(7)[i] = -a-b-c;
            
            /*
            ppp[i] = Math.abs(a+b+c);
            ppm[i] = Math.abs(a+b-c);
            pmp[i] = Math.abs(a-b+c);
            pmm[i] = Math.abs(a-b-c);
            mpp[i] = Math.abs(-a+b+c);
            mmp[i] = Math.abs(-a-b+c);
            mpm[i] = Math.abs(-a+b-c);
            mmm[i] = Math.abs(-a-b-c);
            */
        }
        Arrays.sort(li.get(0),Comparator.reverseOrder());
        Arrays.sort(li.get(1),Comparator.reverseOrder());
        Arrays.sort(li.get(2),Comparator.reverseOrder());
        Arrays.sort(li.get(3),Comparator.reverseOrder());
        Arrays.sort(li.get(4),Comparator.reverseOrder());
        Arrays.sort(li.get(5),Comparator.reverseOrder());
        Arrays.sort(li.get(6),Comparator.reverseOrder());
        Arrays.sort(li.get(7),Comparator.reverseOrder());
        /*
        Arrays.sort(ppp,Comparator.reverseOrder());
        Arrays.sort(ppm,Comparator.reverseOrder());
        Arrays.sort(pmp,Comparator.reverseOrder());
        Arrays.sort(pmm,Comparator.reverseOrder());
        Arrays.sort(mpp,Comparator.reverseOrder());
        Arrays.sort(mmp,Comparator.reverseOrder());
        Arrays.sort(mpm,Comparator.reverseOrder());
        Arrays.sort(mmm,Comparator.reverseOrder());
        */
        long ans = -Long.MAX_VALUE;
        for(int i = 0; i < 8; i++){
            long tmp = 0;
            for(int j = 0; j < m; j++){
                tmp += li.get(i)[j];
            }
            ans = Math.max(ans,tmp);
        }
        /*
        ans = Math.max(ans,ppp[0] + ppp[1] + ppp[2]);
        ans = Math.max(ans,ppm[0] + ppm[1] + ppm[2]);
        ans = Math.max(ans,pmp[0] + pmp[1] + pmp[2]);
        ans = Math.max(ans,pmm[0] + pmm[1] + pmm[2]);
        ans = Math.max(ans,mpp[0] + mpp[1] + mpp[2]);
        ans = Math.max(ans,mmp[0] + mmp[1] + mmp[2]);
        ans = Math.max(ans,mpm[0] + mpm[1] + mpm[2]);
        ans = Math.max(ans,mmm[0] + mmm[1] + mmm[2]);
        */
        System.out.println(ans);
    }
}

Measured memory_bytes: 29144
while true
	h,w = gets.split.map(&:to_i)
	break if h == 0 && w == 0
	for i in (1..h) do
		for j in (1..w) do
			if (i+j)% 2 == 0
				print "#"
			else
				print "."
			end
		end
		puts
	end
	puts
end


Measured memory_bytes: 6872
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e2;
const int MAX_W = 1e5;
int64_t dp[MAX_N + 1][MAX_W + 1];
// O(NW)
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N, W;
    cin >> N >> W;
    vector<int64_t> w(N), v(N);
    for(int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }
    for(int i = 0; i <= N; i++) {
        for(int j = 0; j <= W; j++) {
            dp[i][j] = -1;
        }
    }
    dp[0][0] = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j <= W; j++) {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            int j_ = j + w[i];
            if(j_ <= W) {
                dp[i + 1][j_] = max(dp[i + 1][j_], dp[i][j] + v[i]);
            }
        }
    }
    int64_t ans = -1;
    for(int j = 0; j <= W; j++) {
        ans = max(ans, dp[N][j]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 79104
A,B = map(int,input().split())
X =list(map(int,input().split()))
X = sorted(X)
count = 0
j=len(X)
if B == sum(X):
  print(len(X))
else:
  for i in range(A):
    a = X.pop(0)
    B=B - a
    if B >= 0:
      count += 1
    if B >= 0 and count == j:
      count = count -1
  print(count)

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

bool dist(long long x, long long y, long long d){
    long long D=(long long)(d*d);
    long long dis = (long long)(x*x) + (long long)(y*y);
    if(dis<=D){
        return true;
    }
    return false;
}
int main(){
    long long n, d;
    cin>>n>>d;
    int val=0;
    while (n--)
    {
        /* code */
        long long x, y;
        cin>>x>>y;
        if(dist(x, y, d)){
            val++;
        }
    }
    cout<<val<<'\n';
    
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

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

using ll = long long int;
using pll = pair<ll, ll>;

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

    int n = 0;
    rep (i, s.size()) { if (s[i] == 'o') { ++n; } }

    cout << ((15 - s.size() + n) >= 8 ? "YES" : "NO") << endl;

    return 0;
}


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

/*------------------------------------------------------------------*/

#define ll long long int
#define mp make_pair
#define pb push_back
#define MOD 1000000007

bool isvowel(char c)
{
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
        return true;
        return false;
}
ll isprime(ll n)
{
    ll ans=1;
    for(ll i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            ans = i;
    }
    return ans;
}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    if(b==1)
        return a%m;
    ll temp=power(a,b/2,m);
    if(b%2==0)
        return ((temp%m)*(temp%m))%m;
    else
        return ((((temp%m)*(temp%m))%m)*a%m)%m;
}

/*-----------------------------------------------------------------------------*/

ll c(ll n, ll k)
{
    ll C[n + 1][k + 1];
    ll i, j;

    for (i = 0; i <= n; i++)
    {
        for (j = 0; j <= min(i, k); j++)
        {

            if (j == 0 || j == i)
                C[i][j] = 1;

            else
                C[i][j] = (C[i - 1][j - 1]%MOD +
                          C[i - 1][j])%MOD;
        }
    }
    return C[n][k]%MOD;
}
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {

        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;


        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;

    return x;
}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    //freopen("1.txt","rt",stdin);
    //freopen("output.txt","wwt",stdout);

    ll t;
    t=1;
    //cin>>t;
    //ll t1=0;
    while(t--)
    {
        char c;
        cin>>c;
        char d=c+1;
        cout<<d;
    }
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+2;
string s,p;
int main()
{
    ft
    ll t,i,j,n,m,a,b,l,r,c=0;
    char ch;
    cin>>s>>t;
    while(t--)
    {
        cin>>l;
        if(l==1)
        {
            c=(c+1)%2;
        }
        else
        {
            cin>>r>>ch;
            if(r==1)
            {
                if(c==0)
                {
                    p+=ch;
                }
                else
                {
                    s.pb(ch);
                }
            }
            else
            {
                if(c==0)
                {

                    s.pb(ch);
                }
                else
                {
                    p+=ch;
                }
            }
        }
    }
    if(c==1)
    {
        reverse(s.begin(),s.end());
        cout<<s<<p<<"\n";
    }
    else
    {
        reverse(p.begin(),p.end());
        cout<<p<<s<<"\n";
    }
    return 0;
}

Measured memory_bytes: 980
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	vector<ll> a(n);
	for( auto &k : a ) cin >> k;
	int cnt = 0;
	for( auto &k : a ){
		if( k < 0 ){
			k *= (-1);
			++cnt;
		}
	}
	cnt %= 2;
	ll min = *(min_element(a.begin(), a.end()));
	cout << accumulate( a.begin(), a.end(), 0ll ) - 2*min*cnt << endl;
	return 0;
}

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

// dfmt off
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;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
// dfmt on

void main()
{
    long S = lread();
    long d = (S + (10 ^^ 9) - 1) / (10 ^^ 9);
    long m = ((10 ^^ 9) - S % (10 ^^ 9)) % (10 ^^ 9);
    writefln("0 0 1000000000 1 %d %d", m, d);
}


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

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

  int ans = 0;
  for (int i = 0; i < n-2; i++)
  {
    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') ans++;
  }
  cout << ans << endl;  
}

Measured memory_bytes: 256
N, W = map(int, input().split())

dp = [0] * (W+1)
for i in range(N):
    v, w = map(int, input().split())
    for j in range(W, w-1, -1):
        dp[j] = max(dp[j-w] + v, dp[j])
print(dp[W])


Measured memory_bytes: 5920
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

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

    char prev = '\n';
    int cnt = 0;
    rep(i, n) {
        if (s[i] != prev) {
            prev = s[i];
            ++cnt;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll Nagaemon1;
void swap(ll i,ll j){
  Nagaemon1=i;
  i=j;
  j=Nagaemon1;
}
ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main(void){
  ll n,x;
  cin >> x >> n;
  ll p[n];
  rep(i,n)cin >> p[i];
  ll ans=0,k=0;
  rep(i,x){
    rep(j,n){
      if(p[j]==i){
        k=1;
        break;
      }
    }
    if(k==0)ans=i;
    k=0;
  }
  for(ll i=x;i<2*x-ans;i++){
    rep(j,n){
      if(p[j]==i){
        k=1;
        break;
      }
    }
    if(k==0){
      ans=i;
      break;
    }
    k=0;
  }
  cout << ans;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
string s,t;
bool cmp(char x,char y){
	return x>y;
}
int main(){
	cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),cmp);
    if(s < t)
	cout<<"Yes";
	else
	cout<<"No";	
    return 0;
}

Measured memory_bytes: 256
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N,C;
	cin >> N >> C;
	vector<LL> A(N),B(N);
	for(int i=0;i<N;++i){
		cin >> A[i];
	}
	for(int i=0;i<N;++i){
		cin >> B[i];
	}
	vector<vector<LL> > G(N,vector<LL>(C+1,0));
	for(int i=0;i<N;++i){
		for(int x=A[i];x<=B[i];++x){
			LL temp = 1;
			G[i][0] += temp;//x^0;
			for(int c=1;c<=C;++c){
				temp = (temp*x)%MOD;
				G[i][c] += temp;
				if( G[i][c] >= MOD ){
					G[i][c] -= MOD;
				}
			}
		}
	}

	vector< vector<LL> > dp(N,vector<LL>(C+1,0));
	dp[0] = G[0];
	
	for(int i=1;i<N;++i){
		for(int now=0;now<=C;++now){
			//dp[i][now]
			for(int k=C-now;k>=0;--k){
				dp[i][now+k] = (dp[i][now+k] + dp[i-1][now] * G[i][k])%MOD;
			}
		}
	}
	cout << dp[N-1][C] << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	
	
	solve();
}
#pragma endregion //main()


Measured memory_bytes: 2816
#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<vector>

using namespace std;

int main() {
	string a, b;
	cin >> a >> b;
		int len_a = a.size();
		int len_b = b.size();
		if( len_a<len_b ) {
			cout << "LESS" << endl;
		}else if( len_a==len_b ) {
			if( a<b ) {
				cout << "LESS" << endl;
			}else if( a==b ){
				cout << "EQUAL" << endl;
			}else if( a>b ) {
				cout << "GREATER" << endl;
			}
		}else if( len_a>len_b ) {
			cout << "GREATER" << endl;
		}
		

	return 0;
}

Measured memory_bytes: 256
package main

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

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func strSprit(str string) []string {
	cols := strings.Split(str, " ")
	return cols
}

func parseInt(str string) int {
	n, _ := strconv.Atoi(str)
	return n
}

func intSprit(str string) []int {
	strs := strSprit(str)
	cols := make([]int, len(strs))
	for i, v := range strs {
		cols[i] = parseInt(v)
	}
	return cols
}

func bitCount(n uint) int {

	x := uint64(n)

	const m = 1<<64 - 1
	const m0 = 0x5555555555555555
	const m1 = 0x3333333333333333
	const m2 = 0x0f0f0f0f0f0f0f0f

	x = x>>1&(m0&m) + x&(m0&m)
	x = x>>2&(m1&m) + x&(m1&m)
	x = (x>>4 + x) & (m2 & m)
	x += x >> 8
	x += x >> 16
	x += x >> 32

	return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
	return ((n >> uint(i)) & 1) == 1
}

func setBit(d, n int) int {
	t := 1 << uint(n)
	return d | t
}

func intAbs(n int) int {
	return int(math.Abs(float64(n)))
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////
type UnionFind struct {
	Parent []int
}

func (uf *UnionFind) init(n int) {
	uf.Parent = make([]int, n+1)
	for i := 0; i <= n; i++ {
		uf.Parent[i] = -1
	}
}

func (uf *UnionFind) root(n int) int {
	if uf.Parent[n] < 0 {
		return n
	}
	uf.Parent[n] = uf.root(uf.Parent[n])
	return uf.Parent[n]
}

func (uf *UnionFind) issame(x, y int) bool {
	return uf.root(x) == uf.root(y)
}

func (uf *UnionFind) merge(x, y int) bool {
	x = uf.root(x)
	y = uf.root(y)

	if x == y {
		return false
	}
	if uf.Parent[x] > uf.Parent[y] {
		x, y = y, x
	}
	uf.Parent[x] += uf.Parent[y]
	uf.Parent[y] = x
	return true
}

func (uf *UnionFind) size(n int) int {
	return -uf.Parent[uf.root(n)]
}

func main() {
	line := nextLine()
	spl := intSprit(line)

	N, M := spl[0], spl[1]

	qa := make([]int, M)
	qb := make([]int, M)

	for i := 0; i < M; i++ {
		s := intSprit(nextLine())
		qa[i] = s[0]
		qb[i] = s[1]
	}

	var uf UnionFind
	uf.init(N)

	res := make([]int64, M)
	cur := (int64(N) * int64(N-1)) / (int64(2))

	for i := M - 1; i >= 0; i-- {
		res[i] = cur

		a, b := qa[i], qb[i]
		if uf.issame(a, b) {
			continue
		}

		sa, sb := int64(uf.size(a)), int64(uf.size(b))

		cur -= sa * sb
		uf.merge(a, b)
	}

	for i := 0; i < M; i++ {
		fmt.Println(res[i])
	}
}


Measured memory_bytes: 8704
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;





// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    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;
    }
    
    // for prime mod
    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;
    }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(){
    int n;
    cin >> n;
    int ans=0;
    rep(i,n+1){
        ans+=i;
    }
    cout << ans;
    rn 0;
    
    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    void solve() {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int X = sc.nextInt();

        for (int i = X - K + 1; i <= X + K -1 ; i++) {
            System.out.print(i + " ");
        }
    }

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

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


/*int main(){
    long long int x,y,z,xk,yk,zk,minimum,kouyaku;
    cin >> x >> y >> z;
    /*if(x>y){
        minimum=min(y,z);
    }else{
        minimum=min(x,z);
    }
    cout << minimum <<endl;
    int saidai;
    for(int i=x;i>1;i--){
        xk=x%i;
        yk=y%i;
        zk=z%i;

        if(xk==0 && yk==0 && zk==0){
            kouyaku=i;
            cout<<i;
        }

    }
}*/
int gcd(int a, int b);

int main(){
    long long int k,num1,num2,sum;
    cin >> k;
    sum=0;
    for(int i=1;i<=k;i++){
        for(int j=1;j<=k;j++){
            for(int n=1;n<=k;n++){
                num1=gcd(i,j);
                num2=gcd(num1,n);
                sum+=num2;
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}

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

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
using namespace std;
typedef long long ll;

void solve(){
  ll a, v, b, w, t; cin >> a >> v >> b >> w >> t;
  string ans;
  if(a <= b){
    if(a + v * t >= b + w * t) ans = "YES";
    else ans = "NO";
  }
  else{
    if(a - v * t <= b - w * t) ans = "YES";
    else ans = "NO";
  }
  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 3632
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

const int MAXN = 100010;

int n;
vector<int> g[100010];

int zeit, dis[MAXN], fin[MAXN], low[MAXN], par[MAXN], dep[MAXN];
int kodat[MAXN], koptr[MAXN + 1];
void dfsInfo(int u,int oy,int d){
	dis[u] = low[u] = zeit++; par[u] = oy; dep[u] = d;
	int v;
	rep(i,sz(g[u])) if((v = g[u][i]) != oy){
		if(!~dis[v]){
			dfsInfo(v, u, d + 1);
			low[u] = min(low[u], low[v]);
		} else {
			low[u] = min(low[u], dis[v]);
		}
	}
	fin[u] = zeit++;
}

void dfsInfos(){
	memset(dis, ~0, n*4); zeit = 0;
	rep(u,n) if(!~dis[u]) dfsInfo(u, -1, 0);
	rep(u,n){
		int &j = koptr[u + 1] = koptr[u];
		rep(i,sz(g[u])) if(u == par[g[u][i]]) kodat[j++] = g[u][i];
	}
}

bool produce(int u,int v){
	return (dis[u] <= dis[v] && fin[u] >= fin[v]);
}

int related(int u,int v){
	int s = koptr[u], e = koptr[u+1], h;
	while(s+1 < e){
		h = (s + e) >> 1;
		(dis[kodat[h]] <= dis[v]) ? s = h : e = h;
	}
	return kodat[s];
}

bool isBridge(int u,int v){
	if(dis[u] > dis[v]) swap(u, v);
	return (u == par[v] && dis[v] <= low[v]);
}

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

	int m;
	cin>>n>>m;
	rep(i,m){
		int a,b;
		cin>>a>>b;
		g[a].pb(b);
		g[b].pb(a);
	}
	rep(i,n)sort(g[i].begin(),g[i].end());
	dfsInfos();
	rep(i,n)rep(j,sz(g[i])){
		if(i<g[i][j] && isBridge(i,g[i][j]))cout<<i<<" "<<g[i][j]<<endl;
	}
}

Measured memory_bytes: 5964
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string A, B, C; cin >> A >> B >> C;
    cout << A[0] << B[0] << C[0];
    cout << endl;
    return 0;
}





Measured memory_bytes: 256
use text_io::*;
use std::collections::HashMap;
use std::process::exit;
use std::collections::BTreeMap;

fn main() {
    let mut a:String = read!();
    let mut b:String = read!();
    let mut n:usize = read!();
    let mut m:usize = read!();
    let mut c:String = read!();
    if a==c {
        println!("{} {}",n-1,m);
    }
    else {
        println!("{} {}",n,m-1);
    }
}

Measured memory_bytes: 2168
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int main()
{
    int r;
    string s,a,b;
    cin>>r;
    cin>>s;
    if(r%2==1)
    {
        cout<<"No"<<endl;
        return 0;
    }
    a=s.substr(0,r/2);
    b=s.substr(r/2,r/2);
    if(a==b)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef double db;

#define mp make_pair
#define pb push_back
#define pt(i) printf("%lld\n",(ll)i)
#define mp make_pair
#define ff first
#define ss second
#define pi acos(-1.0)

ll in() { ll a;scanf("%lld",&a); return a;}
db din(){ db a;scanf("%lf",&a); return a; }
ll bigmod(ll b, ll p,ll md){if(p==0) return 1;if(p%2==1){ return ((b%md)*bigmod(b,p-1,md))%md;} else {ll y=bigmod(b,p/2,md);return (y*y)%md;}}
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b);}

long long getRandom(long long a,long long b){
    long long ret = (long long)rand()*(long long)rand();
    ret %= (b - a + 1);
    ret += a;
    return ret;
}

int dp[100005],ar[100005];

int solve(int pos)
{
	if(pos==0)
		return 0;
	if(dp[pos]!=-1)
		return dp[pos];
	if(pos==1)
		return dp[pos]=abs(ar[0]-ar[1]);
	return dp[pos]=min(abs(ar[pos]-ar[pos-1])+solve(pos-1),abs(ar[pos]-ar[pos-2])+solve(pos-2));
}

int main()
{
//	freopen("in.c","r",stdin);
//	freopen("out.c","w",stdout);
	int n=in();
	for(int i=0;i<n;i++)
		ar[i]=in();
	reverse(ar,ar+n);
	memset(dp,-1,sizeof dp);
	pt(solve(n-1));
}

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

int main() {
	int n;
	cin>>n;
	for(int i=0,num[3];i<n;i++){
		for(int j=0;j<3;j++)cin>>num[j];
		num[0]--;
		num[1]--;
		int ans=num[0]/3*590+num[0]%3*195;
		if((num[0]+1)%3==0)ans+=num[1]*20;
		else ans+=num[1]/2*39+num[1]%2*20;
		cout<<196471-ans-num[2]<<endl;
	}
}

Measured memory_bytes: 1160
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, a[200009];
long long ans;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);
	ans += a[0];
	int cur = 1, cnt = 2;
	for (int i = 2; i < n; i++) {
		ans += a[cur];
		cnt--;
		if (cnt == 0) {
			cnt = 2;
			cur++;
		}
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

Measured memory_bytes: 4440
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

const double eps = 1e-8;
const double pi  = acos(-1.0);
inline bool le(const double a, const double b){ return a < b + eps; }
inline bool eq(const double a, const double b){ return abs(a-b) < eps; }

struct P{
    double x, y, arg = 0;
    P(double x = 0, double y = 0) : x(x), y(y){}

    double get_arg(){
        if(!eq(y, 0)){
            arg = acos(x / sqrt(x*x + y*y));
            if(y < 0) arg = pi*2 - arg;
        }else if(x < 0){
            arg = pi;
        }else{
            arg = 0;
        }
        return arg;
    }

    bool operator<(const P &p)const { return arg < p.arg; }
    P operator +(const P& r) const { return P(x+r.x, y+r.y); }
    P operator -(const P& r) const { return P(x-r.x, y-r.y); }
    double sqr(){ return x*x+y*y; }
    double L2norm(){ return sqrt(sqr()); }
    P normalize(){ return P(x/L2norm(), y/L2norm()); }
    double dot(const P& r) const { return x*r.x + y*r.y; }
    double det(const P& r) const { return x*r.x - y*r.y; }
    P rotate(double rad){
        double c = cos(rad), s = sin(rad);
        return P(c*x-s*y, s*x+c*y);
    }
    P rotate_euler(double deg){
        return rotate(deg*pi/180);
    }
};
P operator*(const double& c, const P& p){ return P(c*p.x, c*p.y); }
P operator*(const P& p, const double& c){ return P(p.x*c, p.y*c); }
P operator/(const P& p, const double& c){ return P(p.x/c, p.y/c); }

istream& operator>>(istream& is, P& p){ is >> p.x >> p.y; return is; }
ostream& operator<<(ostream& os, const P& p){ os << p.x << ", " << p.y; return os; }

bool is_intersecting(const P& c1, double r1, const P& c2, double r2, P& a, P& b){
    double d = (c1-c2).L2norm();
    if(le(r1+r2, d)) return false;
    double x = (r1*r1-r2*r2+d*d)/d/2;
    double y = sqrt(max(0.0, r1*r1-x*x));
    P h = (c2-c1).normalize();
    P v = h.rotate_euler(90) * y;
    h = c1 + h * x;
    a = h + v;
    b = h - v;
    return true;
}

int main(void){
    int n;
    cin >> n;
    vector< P > p(n);
    for(int i=0;i<n;i++) cin >> p[i];

    double ng = 0, ok = 1e4;
    for(int t=0;t<(1<<6);t++){
        double mid = (ng + ok)/2;
        bool flg = true;
        vector< P > c;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                P u, v;
                if(!is_intersecting(p[i], mid, p[j], mid, u, v)){
                    flg = false;
                    break;
                }
                c.push_back(u);
                c.push_back(v);
            }
            if(!flg) break;
        }
        if(flg){
            flg = false;
            for(P v: c){
                bool flg2 = true;
                for(int i=0;i<n;i++){
                    if(!le((v-p[i]).sqr(), mid*mid+eps)){
                        flg2 = false;
                        break;
                    }
                }
                if(flg2){
                    flg = true;
                    break;
                }
            }
        }
        if(flg) ok = mid;
        else ng = mid;
    }
    cout << fixed << setprecision(12) << ok << endl;
}


Measured memory_bytes: 460
#include <iostream>
#include <utility> // pair
#include <queue>
using namespace std;

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

typedef pair<int,int> P;

#define mp make_pair
#define ft first
#define sd second

int w, h;
int d[100][100];

P sp[6];
int t;

void set_d(int i, int j) {
	queue<P> q;
	q.push(mp(i, j));
	P p;
	while(!q.empty()) {
		p = q.front();
		q.pop();
		if(p.ft<0 || p.ft>=w)continue;
		if(p.sd<0 || p.sd>=h)continue;
		if(d[p.ft][p.sd])continue;
		d[p.ft][p.sd] = 2;
		P sp[6];
		rep(i, 6) {
			sp[i] = mp( p.ft+(i%2)-(p.sd&1), p.sd-1+(i/2) );
		}
		if(p.sd&1) sp[3].ft += 1;
		else sp[2].ft -= 1;
		rep(i, 6) q.push(sp[i]);
	}
}

int main() {
	cin >> w >> h;
	
	rep(i, h) {
		rep(j, w) cin >> d[j][i];
	}
	
	rep(i, h) set_d(0, i);
	rep(i, h) set_d(w-1, i);
	rep(i, w) set_d(i, 0);
	rep(i, w) set_d(i, h-1);
	
	int s = 0;
	rep(i, w) {
		rep(j, h) {
			if(d[i][j]!=1) continue;
			P p[6];
			rep(k, 6) {
				p[k] = mp( i+(k%2)-(j&1), j-1+(k/2) );
			}
			if(j&1) p[3].ft += 1;
			else p[2].ft -= 1;
			rep(k, 6) {
				if( (p[k].ft<0 || p[k].ft>=w) || (p[k].sd<0 || p[k].sd>=h) ) {
					s++;
				}else if(d[p[k].ft][p[k].sd]==2) {
					s++;
				}
			}
		}
	}
	
	cout << s << endl;
	
	return 0;
}

Measured memory_bytes: 1268
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);


	int n;
const int MAX=INT_MAX/10;
int main(){
	cin>>n;
	vs s(n);
	getline(cin,s[0]);
	REP(i,n){
		getline(cin,s[i]);
	}
	vvi cost(n+2,vi(n+2,MAX));
	cost[0][1]=0;
	REP(i,n){
		if(s[i][s[i].size()-1]==';'&&string(s[i].begin(),s[i].begin()+5)=="goto "){
			string label(s[i].begin()+5,s[i].end()-1);
			REP(j,n){
				if(string(s[j].begin(),s[j].end()-1)==label){
					cost[i+1][j+1]=0;
					break;
				}
			}
			cost[i+1][i+2]=min(1,cost[i+1][i+2]);
		}else{
			cost[i+1][i+2]=0;
		}
	}

	REP(k,n+2){
		REP(i,n+2){
			REP(j,n+2){
				cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
			}
		}
	}

	cout<<cost[0][n+1]<<endl;
}

Measured memory_bytes: 1284
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
int main(void){
   int N;
   cin>>N;
   long A[N];
   for(int i=0;i<N;i++){
       cin>>A[i];
   }
   sort(A,A+N);
   int count=0;
   int ans=0;
   for(int i=0;i<N;i++){
          if(A[i]==A[i+1]&&i!=N-1) {count++;}
          else {count++;  if(count>A[i]){ans+=count-A[i];} if(count<A[i]){ans+=count;} count=0;}
   }
   cout<<ans;
   return 0;
}


Measured memory_bytes: 1024
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)


#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
"""
愚直に操作を実装する
"""
#solution:
cond=1
N=int(input())
A=list(pin())
for num in A:
    if num%2==0:
        if num %3!=0 and num%5!=0:
            cond= 0
print(["DENIED","APPROVED"][cond])
#print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])



Measured memory_bytes: 6572
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 200055
#define M 200005
#define LL long long
#define FF(i, a, b) for(int i = a; i <= b; ++i)
#define RR(i, a, b) for(int i = a; i >= b; --i)
#define FJ(i, a, b) for(int i = a; i < b; ++i)
#define SC(x) scanf("%d", &x)
#define SCC(x, y) scanf("%d%d", &x, &y)
#define SCCC(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define SS(x) scanf("%s", x)
#define PR(x) printf("%d\n", x)
#define CL(a, x) memset(a, x, sizeof(a))
#define _P fd[rt]
#define _L fd[rt << 1]
#define _R fd[rt << 1 | 1]
#define MID int mid = ((l + r) >> 1)
#define lson rt<<1 ,l, mid
#define rson rt<<1 | 1, mi d + 1, r
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define MP make_pair
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
using namespace std;
const int MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-8;
inline void II(int &n){char ch = getchar(); n = 0; bool t = 0;
for(; ch < '0'; ch = getchar()) if(ch == '-') t = 1;
for(; ch >= '0'; n = n * 10 + ch - '0', ch = getchar()); if(t) n =- n;}
inline void OO(int a){if(a < 0) {putchar('-'); a = -a;}
if(a >= 10) OO(a / 10); putchar(a % 10 + '0');}
int n, m, a, b;
LL f[N], l[N], r[N], sr[N];
LL tot;
inline void up(LL &x, LL y){
    if(y > x) x = y;
}
int main(){
  //  IN;
    SC(n);SC(m);
    SC(a);
    FF(i, 2, n){
        SC(b);
        if(a > b) b += m;
        tot += b - a;
        ++l[a]; ++r[b];
        sr[b] += b - a - 1;
        a = b > m ? b - m : b;
    }
    LL cur = 0;
    FF(i, 2, m * 2){
        f[i] = f[i - 1] - sr[i - 1] + cur;
        cur += l[i - 1];
        cur -= r[i];
    }
    LL ans = 0;
    FF(i, 1, m) up(ans, f[i] + f[i + m]);
    ans = tot - ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e3+7;
int a[maxn];
int main()
{
    int n, sum=0;
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>a[i];
    sort(a, a+n);
    for(int i=0; i<n; i++)
        for(int j=i+1; j<n; j++)
        {
            int t1=lower_bound(a,a+n, a[i]+a[j])-a;
            sum+=t1-j-1;
            //cout<<t1<<endl;
        }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int a = Math.min(n, 4);
		int[] num = new int[n];
		for (int i = 0; i < n; i++)
			num[i] = scanner.nextInt();
		Arrays.sort(num);
		List<Integer> ans = new ArrayList<Integer>();
		for (int i = 0; i < a; i++)
			for (int j = 0; j < a; j++) {
				if (i == j)
					continue;
				ans.add(Integer.valueOf(String.valueOf(num[i])
						+ String.valueOf(num[j])));
			}
		Collections.sort(ans);
		System.out.println(ans.get(2));

	}
}

Measured memory_bytes: 30312
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
    class Class97
    {
        static void Main()
        {
            long N = int.Parse(Console.ReadLine());
            long ans = 0;
            for (int i = 0; i < N; i++)
                ans += i;
            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl;
#define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;}
#define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;}
#define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl;
// iterate
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define all(v) v.begin(), v.end()
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q;cin>>n>>q;
    string s;cin>>s;

    vector<ll> L(n+1,0);
    L[0]=0;
    L[1]=0;
    for(int i=2; i<=n; i++){
        if(s.substr(i-2,2)=="AC"){
            L[i]++;
        }
    }
    for(int i=0;i<n;i++){
        L[i+1] += L[i];
    }

    rep(a,q){
        int l,r;cin>>l>>r;
        cout << L[r]-L[l] << endl;
    }
    return 0;
}

Measured memory_bytes: 1872
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    int n;  cin >> n;
    int a[3];
    rep(i, 3)	cin >> a[i];
    vector<int>l(n);
    rep(i, n)	cin >> l[i];
    //solve
    int ans = 1000000000;
    stack<string>st;	//0:使用しない 1:a 2:b 3:c
    st.push("");
    while(!st.empty()){
	string now = st.top();
	st.pop();
	if(now.size() == n){	//それぞれの竹の割り振り完了時
	    int mp = 0;
	    vector<vector<int> >bam(4);
	    rep(i, n){
		bam[now[i]-'0'].push_back(l[i]);
	    }
	    for(int i = 1; i <= 3; i++){
		while(bam[i].size() >= 2){  //それぞれを合成
		    bam[i][0] += bam[i][bam[i].size()-1];
		    bam[i].pop_back();
		    mp += 10;
		}
	    }
	    //この時点でbam[i]のそれぞれの要素は一つまたはゼロ
	    bool flag = true;	//true:各要素に一つ以上竹がある
	    for(int i = 1; i <= 3; i++){
		if(bam[i].empty()){
		    flag = false;
		}else{
		    mp += abs(a[i-1]-bam[i][0]);
		}
	    }
	    if(!flag)	continue;
	    ans = min(ans, mp);
	}else{
	    for(int i = 0; i < 4; i++){
		string next = now + to_string(i);
		st.push(next);
	    }
	}
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

const int MAXN = 305;

int plate[5];
double dp[MAXN][MAXN][MAXN];
int n;

double solve(int one, int two, int three) {
    if (one + two + three == 0) return 0;
    if (dp[one][two][three] > 0) return dp[one][two][three];

    double& ans = dp[one][two][three];
    ans = 1;
    if (one > 0) ans += ((1.0 * one) / n) * solve(one - 1, two, three);
    if (two > 0) ans += ((1.0 * two) / n) * solve(one + 1, two - 1, three);
    if (three > 0) ans += ((1.0 * three) / n) * solve(one, two + 1, three - 1);
    if (one + two + three < n) ans = (ans * n) / (1.0 * one + two + three);
    return ans;
}

int main(void) {
    int a;

    scanf(" %d", &n);
    for (int i = 0; i < n; i++) {
        scanf(" %d", &a);
        plate[a]++;
    }
    double ans = solve(plate[1], plate[2], plate[3]);
    printf("%.12f\n", ans);

    return 0;
}


Measured memory_bytes: 219392
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    string s;
    cin >> s;
    int n = s.size();

    vector<int> accum(n+1, 0);
    int base = 10;
    RFOR(i, n-1, 0){
        accum[i] = (accum[i+1] + base*(s[i]-'0')) % 2019;
        base = (base * 10) % 2019;
    }

    vector<int> left_kazu(n+1, 0);
    vector<int> kiroku(2019, 0);
    REP(i, n+1){
        left_kazu[i] = kiroku[accum[i]];
        kiroku[accum[i]]++;
    }

    ll ans = 0;
    RFOR(i, n, 0){
        ans += left_kazu[i];
    }

    cout << ans << endl;
    



    return 0;
}

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

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL); 
	cout.tie(NULL);
	
	int n;
	cin>>n;
	int k;
	bool hasSev = false;
	
	do{
		k = n%10;
		if(k == 7){
			hasSev = true;
			break;
		}
		n=n/10;
	}while(n > 0);
  
	if(hasSev){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s, t, u;
    cin >> n;
    cin >> s;
    t = s.substr(0, n / 2);
    u = s.substr(n / 2, n / 2);
    if (s.size() % 2 != 0)
    {
        cout << "No" << endl;
    }
    else if (t == u)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順

using namespace std;
using ll = long long int;

int main(){
    ll X;cin>>X;
    ll sum = 100;
    int year = 0;
    while(sum<X){
        sum += sum / 100;
        year++;
    }
    cout << year << endl;
    return 0;
}

Measured memory_bytes: 3596
#!/usr/bin/env python3

import sys, math
sys.setrecursionlimit(300000)


def solve(N: int, X: int, T: int):
    ret = T * math.ceil(N / X)
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    solve(N, X, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 62156