akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::string S, T; std::cin >> S >> T;
  std::string ans;
  rep(i,N) {
    ans += S[i];
    ans += T[i];
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int rgb = input[0] * 100 + input[1] * 10 + input[2];
            Console.WriteLine(rgb % 4 == 0 ? "YES" : "NO");
        }
    }
}

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

int main()
{
  int N;
  
  cin>>N;
  
  switch(N%10)
  {
      case 2:
      case 4:
      case 5:
      case 7:
      case 9:
        cout<<"hon"<<endl;
          break;
      
      case 0:
      case 1:
      case 6:
      case 8:
       cout<<"pon"<<endl;
         break;
      
      case 3:
       cout<<"bon"<<endl;
       break;

  }
  return 0;
}

Measured memory_bytes: 3632
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<Integer> n = new ArrayList<Integer>();
		List<Integer> x = new ArrayList<Integer>();
		List<Integer> count = new ArrayList<Integer>();

		 for(int i=0;;i++){
			 n.add(i, scan.nextInt());
			 x.add(i, scan.nextInt());
			 count.add(i, 0);
			 if(n.get(i)==0 && x.get(i)==0) break;
		 }



   for(int h=0;;h++){
		 if(n.get(h)==0 && x.get(h)==0) break;
		 for(int i=1;i<=n.get(h);i++){
			 for(int j=i;j<=n.get(h);j++){
				 if(i==j)continue;
				 for(int k=j;k <= n.get(h);k++){
					 if(i==k || j==k)continue;
					 if(i+j+k == x.get(h)) count.set(h, count.get(h)+1 );
				 }
			 }
		 }

			System.out.println(count.get(h));
   }
	}

}

Measured memory_bytes: 29232
#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 = 1000000007;

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> cnt(N);

  vector<int> a(M), b(M);
  rep(i, M) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    cnt[a[i]]++;
    cnt[b[i]]++;
  }
  rep(i, N) { cout << cnt[i] << endl; }
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

#define endl '\n'

typedef long long ll;
typedef long double lb;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<string, int> psi;

inline bool inside(int y, int x, int H, int W)
{ 
  return (y >= 0 && x >= 0 && y < H && x < W);
}

inline int in() {int x; std::cin >> x; return x;}

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

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

  while (cin >> s){
         if (s[0] == s[1] && s[1] == s[2] && s[0] != 's') cout << s[0] << endl;
    else if (s[3] == s[4] && s[4] == s[5] && s[3] != 's') cout << s[3] << endl;
    else if (s[6] == s[7] && s[7] == s[8] && s[6] != 's') cout << s[6] << endl;

    else if (s[0] == s[3] && s[3] == s[6] && s[0] != 's') cout << s[0] << endl;
    else if (s[1] == s[4] && s[4] == s[7] && s[1] != 's') cout << s[1] << endl;
    else if (s[2] == s[5] && s[5] == s[8] && s[2] != 's') cout << s[2] << endl;

    else if (s[0] == s[4] && s[4] == s[8] && s[4] != 's') cout << s[4] << endl;
    else if (s[2] == s[4] && s[4] == s[6] && s[4] != 's') cout << s[4] << endl;

    else cout << 'd' << endl;
  }
      

  return (0);
}

Measured memory_bytes: 1164
s = list(input())
MOD = 10**9 + 7
cnt = [[] for _ in range(len(s))]
i = len(s) - 1
de = 1

while i >= 0:
    if s[i] == '?':
        for j in range(10):
            cnt[i].append((j * de) % 13)
    else: cnt[i].append((int(s[i]) * de) % 13)
    i -= 1
    de *= 10
    de %= 13

dp = [[0]*13 for _ in range(len(s))]
for i in cnt[0]:
    dp[0][i] = 1
for i in range(1, len(s)):
    for j in cnt[i]:
        for k in range(13):
            if dp[i-1][k] != 0:
                dp[i][(j + k)%13] += dp[i - 1][k]
                dp[i][(j + k)%13] %= MOD
print(dp[-1][5])


Measured memory_bytes: 117964
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#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 <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const long long MOD = 1000000007;

int main(void){
    ll sx, sy,tx,ty;
    string ans;
    cin >> sx >> sy >> tx >> ty;
    REP(i,ty-sy){
        ans.push_back('U');
    }
    REP(i,tx-sx){
        ans.push_back('R');
    }
    REP(i,ty-sy){
        ans.push_back('D');
    }
    REP(i,tx-sx){
        ans.push_back('L');
    }
    ans.push_back('L');
    REP(i,ty-sy+1){
        ans.push_back('U');
    }
    REP(i,tx-sx+1){
        ans.push_back('R');
    }
    ans.push_back('D');
    ans.push_back('R');
    REP(i,ty-sy+1){
        ans.push_back('D');
    }
    REP(i,tx-sx+1){
        ans.push_back('L');
    }
        ans.push_back('U');

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) (x.begin(), x.end())

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    cin >> n;
    if(n==1) cout << "Hello World" << endl;
    else {
        int a, b;
        cin >> a >> b;
        cout << a+b << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<61;
const double pi=acos(-1);
const double eps=1e-10;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vl dp;

int main(){
	cin>>n;
	dp=vl(n+1);
	dp[0]=2;
	dp[1]=1;
	for(int i=2;i<=n;i++) dp[i]=dp[i-1]+dp[i-2];
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    long long ret = 0;
    int min = 0;
    bool flag = true;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        int start = i - x;
        if (start < min)flag = false;
        else if (start == min)ret++;
        else ret += x;
        min = start;
    }
    cout << (flag ? ret - 1 : -1) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <iomanip>
#include <math.h>
#include <time.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define all(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 1147483600;
const ll infl = 1e18 + 5;
const char ENDL = '\n';
//cout << fixed << setprecision(17) << res << endl;
vector<pll> edges[100005];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll k;
    cin >> k;
    vll dist(k, infl);
    dist[1] = 1;
    rep(i,k){
        edges[i].eb(mp(i * 10 % k, 0));
        edges[i].eb(mp((i + 1) % k, 1));
    }
    set<pll> check;
    check.insert(mp(1, 1));
    while (!(check.empty())){
        pll p = *check.begin();
        check.erase(p);
        ll now = p.S;
        for (auto q:edges[now]){
            ll nex = q.F, d = q.S;
            if (dist[nex]>dist[now]+d){
                dist[nex] = dist[now] + d;
                check.insert(mp(dist[nex], nex));
            }
        }
    }
    cout << dist[0] << ENDL;
}


Measured memory_bytes: 11136
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	s = readline() |> chomp
	f = 0
	a = zeros(Int,n)
	b = zeros(Int,n)
	c = zeros(Int,n)
	d = zeros(Int,n)
	a[1] = 1
	a[2] = 1
	b[1] = 1
	b[2] = -1
	c[1] = -1
	c[2] = 1
	d[1] = -1
	d[2] = -1
	for i in 3:n
		f = (s[i-1]=='o'?1:-1)
		a[i] = f*a[i-2]*a[i-1]
		b[i] = f*b[i-2]*b[i-1]
		c[i] = f*c[i-2]*c[i-1]
		d[i] = f*d[i-2]*d[i-1]
	end
	if (s[n]=='o'?1:-1)*a[n]*a[n-1]==a[1]&&(s[1]=='o'?1:-1)*a[n]*a[1]==a[2]
		for i in 1:n
			print(a[i]==1?"S":"W")
		end
		println("")
	elseif (s[n]=='o'?1:-1)*b[n]*b[n-1]==b[1]&&(s[1]=='o'?1:-1)*b[n]*b[1]==b[2]
		for i in 1:n
			print(b[i]==1?"S":"W")
		end
		println("")
	elseif (s[n]=='o'?1:-1)*c[n]*c[n-1]==c[1]&&(s[1]=='o'?1:-1)*c[n]*c[1]==c[2]
		for i in 1:n
			print(c[i]==1?"S":"W")
		end
		println("")
	elseif (s[n]=='o'?1:-1)*d[n]*d[n-1]==d[1]&&(s[1]=='o'?1:-1)*d[n]*d[1]==d[2]
		for i in 1:n
			print(d[i]==1?"S":"W")
		end
		println("")
	else
		println(-1)
	end
end

main()

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

int main() {
  int R;
  cin>>R;
  if(R<1200){
    cout<<"ABC"<<endl;
  }
  else if(R<2800){
    cout<<"ARC"<<endl;
  }
  else{
    cout<<"AGC"<<endl;
  }
}

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

using namespace std;
 
int n, k;
int a[2000010]; 
int max_edge;//ans = k - max_edge
int main()
{
	cin >> k >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		a[i] %= k;
	}
	sort(a+1, a+n+1);
	for(int i = 2; i <= n; i++)
	{
		max_edge = max(max_edge, a[i] - a[i-1]);
	}
	max_edge = max(max_edge, k - a[n] + a[1]); 
	cout << k - max_edge << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#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,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

ll n, a[50];
 
int main(int argc, char **argv) {
	cin >> n;
	REP(i, n) cin >> a[i];
	ll mai = 0;
	REP(i, n) if (abs(a[i]) > abs(a[mai])) mai = i;
	cout << (2*n-2) << endl;
	REP(i, n) {
		if (i == mai) continue;
		a[i] += a[mai];
		cout << (mai + 1) << " " << (i+1) << endl;
	}
	if (a[mai] >= 0) REP(i, n-1) cout << (i+1) << " " << (i+2) << endl;
	else REPR(i, n-1) cout << (i+2) << " " << (i+1) << endl;
	return 0;
}
 

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
    int n, m;
    int i = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &m);
        if (!(m & 1))
        {
            if (!(m % 3 == 0 || m % 5 == 0))
            {
                printf("DENIED\n");
                return 0;
            }
        }
    }
    printf("APPROVED\n");
    return 0;
}

Measured memory_bytes: 128
//integer positif N
//string S panjangnya N isinya lowercase

//tentukan apakah ia gabungan dari 2 string
//yaitu tentukan apakah ada string T yang memenuhi S = T + T

//N max 100
//S sepanjang N
//T itu kemungkinan T = N/2

//input
//integer N, string S

//output
//if S adalah gabungan dari 2 T, print Yes, jika tidak, No

//jadi istilahnya
//inputnya contoh
//6 = panjangnya 6 char
//abcabc		anggpalah T = abc, nah S kan T*T itu jadi abcabc
//jadi sederhananya
//kalo index 123...N di T1, = index 123...N di T2 print Yes, jika tidak No

//dan kalo int nya ganjil, pasti no, soalnya gabisa dibagi 2


#include <stdio.h>
#include <string.h>
int main(){
	int N, sama=0;
	scanf("%d", &N);
	
	if(N%2 != 0)
	{
		puts("No");
		return 0;
	}
	
	char str[N+1];
	scanf("%s", &str);
	int length = strlen(str);
	
	for(int i = 0, j = length/2; i <= length/2; i++, j++)
	{
		if(str[i] == str[j])
		{
			sama++;
		}
	}
	
	if(sama == length/2)
	{
		puts("Yes");
	}
	else 
	{
		puts("No");
	}
	
	return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
int h, w;
bool a[50][50];
bool ok(int x, int y){
  return 0<=x and x < h and 0<= y and y < w and a[x][y];
}
int dx[] = {-1,0,0,1};
int dy[] = {0,-1,1,0};
int main(){
  cin >> h >> w;
  for(int i = 0; i < h; i++){
    string s;
    cin >> s;
    for(int j = 0; j < w; j++){
      a[i][j] = (s[j] == '.');
    }
  }
  int ans = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(!ok(i,j))continue;
      queue<pair<int,int>> q;
      q.emplace(i, j);
      int dist[50][50] = {};
      memset(dist, -1, sizeof(dist));
      int ma = -1;
      dist[i][j] = 0;
      while(!q.empty()){
        auto p = q.front();q.pop();
        ma = max(ma, dist[p.first][p.second]);
        for(int k = 0; k < 4; k++){
          int x = p.first + dx[k];
          int y = p.second + dy[k];
          if(!ok(x,y))continue;
          if(dist[x][y]==-1){
            dist[x][y] = dist[p.first][p.second] + 1;
            q.emplace(x, y);
          }
        }
      }
      ans = max(ma, ans);
    }
  }
  cout << ans << endl;
}


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

int main() {
  
  int N, M;
  cin >> N >> M;
  if(N>=M){cout << "0" << endl; return 0;}
  
  vector<int> Xs(M);
  for(int i=0; i<M; i++){ cin >> Xs.at(i); }
  sort(Xs.begin(), Xs.end());
 
  vector<int> Ls(M-1);
  for(int i=0; i<M-1; i++){
    Ls.at(i) = Xs.at(i+1) - Xs.at(i);
  }
  sort(Ls.begin(), Ls.end(), greater<int>());
  
  int sum=0;
  for(int i=0; i<N-1; i++){
    sum += Ls.at(i);
  }

  cout << Xs.at(M-1)-Xs.at(0)-sum << endl;

}


Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;  // first: 最短距離, second: 頂点番号
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const ll MAX = 510000;
const int MOD = 1000000007;

const ll INF = 1e18;
const ll MAX_V = 1e15;

struct edge {
    ll to;
    ll cost;
    edge(int t, int c) : to(t), cost(c) { }
};

ll V, d_yen[MAX],d_snuke[MAX];
vector<edge> G_yen[MAX]; // 隣接リスト表現
vector<edge> G_snuke[MAX]; // 隣接リスト表現

void dijkstra_yen(ll s) {
    fill(d_yen, d_yen + V, INF);
    d_yen[s] = 0;  // 始点sへの最短距離は0

    priority_queue<P, vector<P>, greater<P> > que;  // 距離が小さい順に取り出せるようgreater<P>を指定
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        ll v = p.second;  // 更新した頂点の中で距離が最小の頂点v
        if (d_yen[v] < p.first) {
            continue;
        }
        for (auto e : G_yen[v]) {  // 頂点vから出る辺eを走査
            if (d_yen[e.to] > d_yen[v] + e.cost) {
                d_yen[e.to] = d_yen[v] + e.cost;
                que.push(P(d_yen[e.to], e.to));
            }
        }
    }
}


void dijkstra_snuke(ll t) {
    fill(d_snuke, d_snuke + V, INF);
    d_snuke[t] = 0;  // 始点sへの最短距離は0

    priority_queue<P, vector<P>, greater<P> > que;  // 距離が小さい順に取り出せるようgreater<P>を指定
    que.push(P(0, t));
    while (!que.empty()) {
        P p = que.top();
        que.pop();
        ll v = p.second;  // 更新した頂点の中で距離が最小の頂点v
        if (d_snuke[v] < p.first) {
            continue;
        }
        for (auto e : G_snuke[v]) {  // 頂点vから出る辺eを走査
            if (d_snuke[e.to] > d_snuke[v] + e.cost) {
                d_snuke[e.to] = d_snuke[v] + e.cost;
                que.push(P(d_snuke[e.to], e.to));
            }
        }
    }
}

int main(){
  ll E;
  cin>>V>>E;
  ll s,t;cin>>s>>t;
  s--;t--;

  rep(i,E){
    ll a,b,yen,snuke;
    cin>>a>>b>>yen>>snuke;
    a--;b--;
    G_yen[a].pb(edge(b,yen));
    G_yen[b].pb(edge(a,yen));
    G_snuke[a].pb(edge(b,snuke));
    G_snuke[b].pb(edge(a,snuke));
  }

  dijkstra_yen(s);
  dijkstra_snuke(t);

  priority_queue<P , vector<P> , greater<P> > que; //小さい順に取り出していく
  rep(i,V){
    ll pay = d_yen[i] + d_snuke[i];
    ll index = i;
    que.push(P(pay,index));
  }
  rep(i,V){
    P p = que.top();
    ll pay = p.first;
    ll index = p.second;
    while(index < i){
      que.pop();
      p = que.top();
      pay = p.first;
      index = p.second;
    }
    cout<<MAX_V - pay <<endl;
  }
}


Measured memory_bytes: 44272
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

ll A[200010];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	ll ans = 0;
	ll num = 0;
	A[N] = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] > i) {
			cout << -1 << endl;
			return 0;
		}
		if (A[i] < A[i + 1] - 1) {
			cout << -1 << endl;
			return 0;
		}
	}
	for (int i = N - 1; i >= 0; i--) {
		if (A[i] != 0) {
			if (A[i] == A[i + 1] - 1) {
				num = max(num, A[i]);
			}
			else {
				ans += num;
				num = A[i];
			}
		}
		else {
			ans += num;
			num = 0;
		}
	}
	cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR(i, 0, (n)-1)
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end());
#define BUG(x) cerr << #x << " = " << (x) << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define _1 first
#define _2 second
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)

int main() {
  int n, k;
  cin >> n >> k;
  cout << n - k + 1;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define spn setprecision
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
struct data
{
	int ind,val;
};
bool cmp(data &a,data &b){
	return(a.val<b.val);
}
const int upperlimit = 55555;
const int limit = 2e5;
bool isprime[upperlimit+1];
int main() {
	for(int i = 4; i <= upperlimit; i+=2){
		isprime[i]=1;
	}
	for(int i = 3; i <= sqrt(upperlimit); i+=2){
		for(int j = i*i; j <= upperlimit; j+=2*i){
			isprime[j]=1;
		}
	}
	int n,cnt=0;
	sd(n);
	for(int i = 11; i <= upperlimit; i += 10){
		if(! isprime[i]){
			pds(i);
			cnt++;
		}
		if(cnt==n){
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
//killer_R@$tog!
#include<bits/stdc++.h>
using namespace std;
#define hell 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)
#define mp make_pair
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define ll long long int
#define N 100009
#define all(b) b.begin(),b.end()
#define sz sizeof
#define shuru(h) memset(h,0,sz(h))
//int pr[N];
//int seg[N];
/*int query(int l,int r,int sl,int sr,int p)
{
    if(r<sl || l>sr)
        return 0;
    if(sr<=r && sl>=l)
        return seg[p];
    int m=sl+(sr-sl)/2;
    return (__gcd(query(l,r,sl,m,2*p+1),query(l,r,m+1,sr,2*p+2)));
}

int build(int l,int r,int p,int arr[])
{
    if(l==r)
    {
        seg[p]=arr[l];
        return seg[p];
    }
    int m=l+(r-l)/2;
    seg[p]=__gcd(build(l,m,2*p+1,arr),build(m+1,r,2*p+2,arr));
    return seg[p];
}
void isprime()
{
    memset(pr,1,sizeof(pr));
    pr[1]=0;
    for(int i=2;i*i<=N;i++)
    {
        if(pr[i])
        {
            for(j=i*i;j<=N;j+=i)
            {
                pr[j]=0;
            }
        }
    }
}*/
void killer()
{
    int n;cin>>n;
    ll a[n+1],dp[n+1][n+1];shuru(dp);
    rep(i,1,n+1)
    {
        cin>>a[i];
        dp[1][i]=a[i];
    }
    rep(i,2,n+1)
    {
        for(int j=1;j+i-1<=n;j++)
        {
            int t=j+i-1;
            dp[i][j]=max(a[j]-(dp[i-1][j+1]),a[t]-(dp[i-1][j]));
        }
    }
    cout<<dp[n][1];
    return;
}
int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    //int h=(int)ceil(log2(n));
    //h=2*(int)pow(2,h)-1;
    //build(0,n-1,0,a);

    ll t;
    t=1;
    while(t--)
        killer();

    return 0;
}

Measured memory_bytes: 70656
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int W = scanner.nextInt();
			int H = scanner.nextInt();
			int N = scanner.nextInt();

			int[][] coodinate = new int[W][H];
			// ironuri
			int x, y, action;
			while (N-- > 0) {
				x = scanner.nextInt();
				y = scanner.nextInt();
				action = scanner.nextInt();
				switch (action) {
				case 1:
					for (int i = 0; i < x; i++)
						for (int j = 0; j < H; j++)
							coodinate[i][j] = 1;
					break;
				case 2:
					for (int i = x; i < W; i++)
						for (int j = 0; j < H; j++)
							coodinate[i][j] = 1;
					break;
				case 3:
					for (int i = 0; i < W; i++)
						for (int j = 0; j < y; j++)
							coodinate[i][j] = 1;
					break;
				case 4:
					for (int i = 0; i < W; i++)
						for (int j = y; j < H; j++)
							coodinate[i][j] = 1;
					break;
				default:
					break;
				}
			}

			int cnt = 0;
			for (int i = 0; i < W; i++) {
				for (int j = 0; j < H; j++) {
					if (coodinate[i][j] == 0)
						cnt++;
				}
			}
			// output
			System.out.println(cnt);
		}
	}
}

Measured memory_bytes: 23016
#include <stdio.h>
#define N 100
#define INF 2147483647
#define NIL -1

int n, a[N][N];

int Prim(){
  int i, u, r = 0, v, mincost, wa = 0;
  int d[N], pi[N], color[N];
  for(u = 0; u < n; u++){
    d[u] = INF;
    pi[u] = NIL;
    color[u] = 0;
  }
  d[r] = 0;
  while(1){
    mincost = INF;
    for(i = 0; i < n; i++){
      if(color[i] != 2 && d[i] < mincost){
	mincost = d[i];
	u = i;
      }
    }
    if(mincost == INF) break;
    
    color[u] = 2;
    
    for(v = 0; v < n; v++){
      if(color[v] != 2 && a[u][v] != INF){
	if(d[v] > a[u][v]){
	  pi[v] = u;
	  d[v] = a[u][v];
	  color[v] = 1;
	}
      }
    }
  }
  for(i = 0; i < n; i++){
    if(pi[i] != NIL){
      wa += a[i][pi[i]];
    }
  }
  
  return wa;
}
  
int main(){
  int i, j;
  int x, aa;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d", &x);
      if(x == -1){
	a[i][j] = INF;
      }else{
	a[i][j] = x;
      }
    }
  }

  aa = Prim();
      

  printf("%d\n", aa);

  return 0;
}



Measured memory_bytes: 1980
#include <cstdio>
#include <queue>
#include <algorithm>

using namespace std;

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
char s[800][801];
int d[800][801];

int main() {
    int h, w, k, x, y, ans = 1e9, i, j;
    queue <pair<int, int> > q;
    
    scanf("%d %d %d", &h, &w, &k);
    
    for (i = 0; i < h; i++) scanf("%s", s[i]);
    
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            if (s[i][j] == 'S') {
                x = i;
                y = j;
            }
        }
    }
    
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            d[i][j] = -1;
        }
    }
    
    d[x][y] = 0;
    q.push(make_pair(x, y));
    
    while (!q.empty()) {
        x = q.front().first;
        y = q.front().second;
        
        q.pop();
        
        if (d[x][y] > k) continue;
        
        ans = min(ans, (x + k - 1) / k + 1);
        ans = min(ans, (h - x - 1 + k - 1) / k + 1);
        ans = min(ans, (y + k - 1) / k + 1);
        ans = min(ans, (w - y - 1 + k - 1) / k + 1);
        
        for (i = 0; i < 4; i++) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            
            if (nx < 0 || nx >= h || ny < 0 || ny >= w || s[nx][ny] == '#') continue;
            
            if (d[nx][ny] == -1) {
                d[nx][ny] = d[x][y] + 1;
                q.push(make_pair(nx, ny));
            }
        }
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 3456
while True:
    m,f,r=map(int,input().split())
    s=m+f
    
    if m==-1 and f==-1 and r==-1:
        break
    elif m==-1 or f==-1:
        print("F")
    elif s>=80:
        print("A")
    elif 65<=s<80:
        print("B")
    elif 50<=s<65:
        print("C")
    elif 30<=s<50:
        if r>=50:
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long x,k,d;
    long long answer = 0;
    cin >> x >> k >>d;
    if(abs(x)/d < k){
        if( (k-abs(x)/d)%2 == 0){
            answer = abs(x)%d;
        }else{
            answer = d-abs(x)%d;
        }
    }else{
        answer = abs(x)-k*d;
    }

    cout << answer << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };

vector<vector<long long>> comb(int n, int r) {
	vector<vector<long long>> v(n + 1, std::vector<long long>(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}

int main() {

	int n, m;
	cin >> n >> m;

	vector<vector<long long>> v;
	v = comb(100, 2);

	int ans = v[n][2] + v[m][2];
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
const int MAX_N = 200010;

int bit[MAX_N], n;

int sum(int i) {
    int s = 0;
    while (i > 0) {
        s += bit[i];
        i -= i & -i;   
    }
    return s;
}

void add(int i, int x) {
    while (i <= n) {
        bit[i] += x;
        i += i & -i;
    }
}
int a[200010];
int b[200010];
int s[200010];
int s2[200010];
int s3[200010];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    n = N;
    rep(i, N) {
        cin >> a[i];
        a[i] -= K;
    }
    s[0] = a[0];
    rep(i, N - 1) {
        s[i + 1] = s[i] + a[i + 1]; 
    }
    rep(i, N) b[i] = s[i];
    map<int, int> mp;
    rep(i, N) {
        mp[s[i]] = i;
    }
    sort(s, s + N);
    
    int cnt = 1;
    rep(i, N) {
        s2[mp[s[i]]] = cnt;
        //cout << "s2[" << mp[s[i]] << "] = " << cnt << endl;
        if (i + 1 != N && s[i] != s[i + 1]) cnt++;
    }
    rep(i, N) s3[i] = s2[mp[b[i]]];
    /*
    rep(i, N) cout << b[i] << " ";
    cout << endl;
    rep(i, N) cout << s3[i] << " ";
    cout << endl;
    rep(i, N) cout << s[i] << " ";
    cout << endl;
    //*/
    
    int ans = 0;
    rep(i, N) {
        add(s3[i], 1);
        if (s[i] >= 0) ans++;
    }
    rep(i, N) {
        //cout << ans << "->";
        ans += sum(N) - sum(s3[i] - 1) - 1;
        add(s3[i], -1);
        //cout << ans << endl;
    }
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 22144
#include <bits/stdc++.h>
#define P pair<int,int>
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int main() {
	int n;
	cin >> n;
	int a[n];
	int Odd = 0, Even = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (!(a[i] % 2)) {
			Even++;
		}
	}
	cout << pow(3, n) - pow(2, Even) << endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N;
    cin >> N;
    string ans = "";
    N--;
    while (1) {
        if(N < 26){
            ans += char('a' + N);
            break;
        }
        ans += char('a' + N % 26);
        N /= 26;
        N--;

    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
N = (gets).to_i
bs = (gets).split(" ").map {|i| i.to_i}

=begin
* つまり与えられた配列をいいかんじに空にするルールを作らないといけない
* i番目にiを挿入するのだから、その逆回しで、i番目からiを摘出する手順を行う
=end

res = []
isOK = true
while (bs.length > 0) && isOK
    isOK = false # ひとつも取り除けなかったら終わる
    (bs.length-1).downto(0) do |i|
        if bs[i] == i+1 then
            res << i+1
            bs.delete_at(i)
            isOK = true
            break
        end
    end
end

if isOK then
    puts res.reverse # 取り除く順番の逆なので
else
    puts "-1"
end

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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  int n;
  while(cin >> n, n){
    vector<int> a(n);
    for(int i = 0; i < n; i++){
      cin >> a[i];
    }
    int ans = INF;
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
        if(i != j){
          ans = min(ans, abs(a[i]-a[j]));
        }
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		solve(a, b, c, d);
	}

	private static void solve(long a, long b, long c, long d) {
		// TODO Auto-generated method stub
		long ans = Long.MIN_VALUE;
		ans = Math.max(ans, a * c);
		ans = Math.max(ans, b * d);
		for (long i = b; i >= a; i--) {
			for (long j = d; j >= c; j--) {
				long t = i * j;
				if (ans > t) break;
				else {
					ans = Math.max(ans, t);
				}
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 27200
a, b, c = map(int, input().split())
ab = abs(a-b)
bc = abs(b-c)

if a == b == c:
  if a % 2 == 0:
    print(-1)
    exit()
  else:
    print(0)
    exit()

count = 0

while True:
  if ab % 2 != 0 or bc % 2 != 0:
    break
  else:
    ab = ab // 2
    bc = bc // 2
    count += 1

print(count)

Measured memory_bytes: 38384
#include<stdio.h>
int main(){

  int i,j,n,count,n2;

  while(1){
    count=0;
    scanf("%d",&n);
    if(n==0)break;

    for(i=1;i<=n/2;i++){
      n2=i;
      for(j=i+1;j<n;j++){
	n2+=j;
	if(n2>n)break;
	if(n2==n){
	  count++;
	  break;
	}
      }
    }
    printf("%d\n",count);
  }
  return 0;
  
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e9
typedef long long ll;
using namespace std;
//�I�[�o�[�t���[�ɋC������您����������
//�m�F�Y���Ȃ您����������

int main() {
    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    int num = v[0];
    int ans = num;
    for(int i = 1; i < n; i++){
        if(v[i]>v[i-1]) ans += v[i]-v[i-1];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int count(int n){
	if(n <= 1){
		return 1;
	}
	if(n == 2){
		return 2;
	}
	if(n == 3){
		return 3;
	}
	if(n == 4){
		return 5;
	}
	if(n == 5){
		return 8;
	}
	if(n == 6){
		return 13;
	}
	if(n == 7){
		return 21;
	}
	return 0;
}
int main(){
	long long int h, w, k;
	cin >> h >> w >> k;
	long long int dp[101][8];
	dp[0][0] = 1;
	for(int i = 1;i < w;i++){
		dp[0][i] = 0;
	}
	for(int i = 1;i <= h;i++){
		for(int j = 0;j < w;j++){
			dp[i][j] = 0;
			if(j != 0){
				dp[i][j]+=(dp[i - 1][j - 1] * count(j - 1) * count(w - j - 1));
			}
			dp[i][j] += dp[i - 1][j] * count(j) * count(w - j - 1);
			if(j != (w - 1)){
				dp[i][j]+=(dp[i - 1][j + 1] * count(j) * count(w - j - 2));
			}
			dp[i][j] %= 1000000007;
		}
	}
	cout << dp[h][k - 1] << endl;
}

Measured memory_bytes: 256
io = STDIN
n,c=io.gets.split.map(&:to_i)
$da=[]
c.times do |i|
  $da << io.gets.split.map(&:to_i)
end
$hash=Hash.new{|h,k|h[k]=Hash.new{|h,k|h[k]=0}}
#key1:amari
#key2:color#-1
#value:count
n.times do |i|
  ar = io.gets.split.map(&:to_i).map{|i|i-1}
  n.times do |j|
    $hash[(i+j)%3][ar[j]]+=1
  end
end
def calc(*arg)
  a,b,c=arg
  tot=0
  #a,b,cはそれぞれあまりが0,1,2の時のに設定する色#-1
  arg.each_with_index do |amari,i|
    cl_cnt=$hash[i]
    cl_cnt.each do |cl,cnt|
      tot+=$da[cl][amari]*cnt
    end
  end
  tot
end

ans=Float::INFINITY
(0...c).to_a.permutation(3) do |x,y,z|
  ans=[calc(x,y,z),ans].min
end
puts ans


Measured memory_bytes: 2428
// A - Christmas Eve Eve Eve
#include <bits/stdc++.h>
using namespace std;

int main(){
	int d; cin>>d;
	cout<< "Christmas";
	if(d<25) cout<< " Eve";
	if(d<24) cout<< " Eve";
	if(d<23) cout<< " Eve";
	cout<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)

N, M = map(int, input().split())

ac_set = set()
wa_dict = {}

for i in range(M):
    p, s = input().split()

    #  ACだった時の処理
    if s == 'AC':
        ac_set.add(p)
    elif s == 'WA':
        if p not in ac_set:
            if wa_dict.get(p) is None:
                wa_dict[p] = 1
            else:
                wa_dict[p] += 1
    else:
        pass

ac_count = len(ac_set)
wa_count = 0

for k, v in wa_dict.items():
    if k in ac_set:
        # WAにカウントする
        wa_count += v

print('{} {}'.format(ac_count, wa_count))


Measured memory_bytes: 14060
// 1_5_C

#include <iostream>
using namespace std;

int main(){
  int H, W;

  while(true){
    cin >> H >> W;
    if(H == 0 && W == 0) return 0;
    for(int i = 0; i < H; i++){
      for(int j = 0; j < W; j++){
        if((i+j)%2 == 0) cout << '#';
        else cout << '.';
      }
      cout << endl;
    }
    cout << endl;
  }
}

Measured memory_bytes: 3088
// header {{{
// header {{{
#include <bits/stdc++.h>
using namespace std;
 
#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y
 
#define ASSERT(expr...) assert((expr))
 
using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
 
using f32 = float;
using f64 = double;
// }}}
 
constexpr i64 INF = 1'010'000'000'000'000'017LL;
 
constexpr i64 MOD = 1'000'000'007LL;
 
constexpr f64 EPS = 1e-12;
 
constexpr f64 PI = 3.14159265358979323846;

#define M5 100007
#define M9 1000000000

 
// util {{{
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
 
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define ll long long int
#define VI vector <ll>
template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
 
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
 
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
 
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}
// }}}
 
// init {{{
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
 
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}
 
//--------------------------------------------------------------------
 
bool isOK(int mid, double key){
 
    if((double)mid*mid > key) {
             return true;
     } else {
              return false;
     }
}

 int binary_search(double key) {
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 2000000000;
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key)) right = mid;
        else left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}


bool isKaibun(string st){
    bool ans = true;
    int n = st.length();
    REP(i,n/2){
        if(st[i] != st[n-i-1]){
            return false;
        }
    }
    return true;
}

int toInt(char a){
    return a-'0';
}

void solve() {
//    int N,S;
string S;
    cin >> S;
    if(S[2]==S[3]&&S[4]==S[5]){
        cout << "Yes";
    }else{
        cout << "No";
    }


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


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
# 単位元とseg_funcを設定する
from fractions import gcd
class seg():
    def __init__(self,init_val):
        self.n=len(init_val)
        self.ide_ele=0 #単位元
        self.num=2**(self.n-1).bit_length() #n以上の最小の2のべき乗
        self.seg=[self.ide_ele]*2*self.num
        for i in range(self.n):
            self.seg[i+self.num-1]=init_val[i]
        for i in range(self.num-2,-1,-1):
            self.seg[i]=self.seg_func(self.seg[2*i+1],self.seg[2*i+2])
    def seg_func(self,a,b):
        return a+b #0
        #return a*b #1
        #return gcd(a,b) #0
        #return max(a,b) #-1か-10**10 (十分小さいもの)
        #return min(a,b) #10**10 (十分大きいもの)
    def update(self,k,x):
        k+=self.num-1
        self.seg[k]=x
        while k:
            k=(k-1)//2
            self.seg[k]=self.seg_func(self.seg[k*2+1],self.seg[k*2+2])
    def query(self,p,q): #O(logN)
        if q<=p:return self.ide_ele
        p+=self.num-1
        q+=self.num-2
        self.res=self.ide_ele
        while q-p>1:
            if p&1==0:
                self.res=self.seg_func(self.res,self.seg[p])
            if q&1==1:
                self.res=self.seg_func(self.res,self.seg[q])
                q-=1
            p=p//2
            q=(q-1)//2
        if p==q:self.res=self.seg_func(self.res,self.seg[p])
        else:self.res=self.seg_func(self.seg_func(self.res,self.seg[p]),self.seg[q])
        return self.res

def main():
    n=int(input())
    A=list(map(int,input().split()))
    seg_A=seg(A)
    dp=[[0]*n for _ in range(n)]  #[i,j]をまとめるために必要なコストの最小値
    for length in range(2,n+1):
        for i in range(n-length+1):
            j=i+length-1 #右側
            res=10**20
            for k in range(i+1,j+1):#区間[i,k)と[k,j]に分ける
                res=min(res,dp[i][k-1]+dp[k][j])
            dp[i][j]=res+seg_A.query(i,j+1)
    print(dp[0][n-1])


if __name__=='__main__':
    main()

Measured memory_bytes: 80248
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define fio() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define MOD 1000000007
#define nl '\n'
#define pb push_back
#define mp make_pair

using namespace std;
const int N = 10;
int32_t main()
{
	fio();
	int n;
	cin>>n;
	int val[n][3];
	int dp[n][3];
	for(int i=0;i<n;i++)
	{
		cin>>val[i][0]>>val[i][1]>>val[i][2];
		dp[i][0]=dp[i][1]=dp[i][2]=100000000000;
	}
	dp[0][0]=val[0][0];
	dp[0][1]=val[0][1];
	dp[0][2]=val[0][2];
	//dp[1]=abs(val[1]-val[0]);
	for(int i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i-1][1]+val[i][0],dp[i-1][2]+val[i][0]);
		dp[i][1]=max(dp[i-1][0]+val[i][1],dp[i-1][2]+val[i][1]);
		dp[i][2]=max(dp[i-1][1]+val[i][2],dp[i-1][0]+val[i][2]);

	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}



Measured memory_bytes: 4992