akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

constexpr int MOD = 1000000007;

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

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

    vector<map<string, int>> a(n);
    rep(i, 0, m) {
        int p;
        string s;
        cin >> p >> s;
        if (s == "WA" && a[p - 1]["AC"] > 0) { continue; }
        ++a[p - 1][s];
    }

    int ans = 0, pen = 0;
    rep(i, 0, n) {
        if (a[i]["AC"] > 0) {
            ans++;
            pen += a[i]["WA"];
        }
    }
    cout << ans << " " << pen << endl;
    return 0;
}

Measured memory_bytes: 26880
#include <iostream>
#include <string>
#include <vector>

using namespace std;

struct Book{
  string title, author;
  string pub_time;
};

int main(){
  int N;
  cin >> N;
  vector<Book> books(N);
  for(int i=0;i<N;++i){
	cin >> books[i].title >> books[i].author >> books[i].pub_time;
  }

  int Q;
  cin >> Q;
  for(int q=0;q<Q;++q){
	string q_name, q_author, q_start, q_end;
	cin >> q_name >> q_author >> q_start >> q_end;

	if(q_name == "*")
	  q_name = "";
	if(q_author == "*")
	  q_author = "";
	if(q_start == "*")
	  q_start = "1970/01/01";
	if(q_end == "*")
	  q_end = "2037/12/31";

	for(int i=0;i<books.size();++i){
	  if(books[i].title.find(q_name) != string::npos
		 && books[i].author.find(q_author) != string::npos
		 && q_start <= books[i].pub_time
		 && books[i].pub_time <= q_end
		 )
		cout << books[i].title << endl;
	}
	if(q != Q-1) cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1236
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        x: usize, a: usize,
    }
    println!("{}", if x < a { 0 } else { 10 });
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#define	MOD  1000000007;
using namespace std;

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

	int a[26];
	for (int i = 0; i < 26; i++)
	{
		a[i] = 0;
	}

	for (int i = 0; i < w.size(); i++)
	{
		a[w[i] - 'a']++;
	}

	for (int i = 0; i < 26; i++)
	{
		if (a[i] % 2 == 1)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	long DIGIT_LIMIT = 1000000000000000000L; //10^18
	long MAX_NUMBER = 59477124183006535L; //pos: 999999999999999985 [10^17, MAX_NUMBER]が最終区間になる
	long[] endK; //endK[k]: 10^k未満の末尾までのインデックス数 便宜的にendK[18]=DIGIT_LIMIT, endK[0]=-1;
	long[] ten; //ten[k] = 10^k ただし、ten[0] = 0
	
	void init(){
		endK = new long[20];
		endK[0] = 0;
		long num = 9;
		for(int k=1;k<=17;k++,num*=10){
			endK[k] = endK[k-1]+k*num;
//			System.out.println("K:"+k+" ENDK:"+endK[k]);
		}
		endK[18] = DIGIT_LIMIT;
		endK[0] = -1;
		ten = new long[20];
		ten[0] = 0;
		ten[1] = 10;
		for(int k=2;k<=17;k++)ten[k]=ten[k-1]*10;
	}
	
	int at(long x){
		long L=0, R=0;
		int k;
		for(k=17;k>=0;k--)if(endK[k] < x){
			L = ten[k];
			R = k==17?MAX_NUMBER:ten[k+1];
			break;
		}
//		System.out.println(L+" "+R+" "+k);
		for(;;){
			long m = (R+L)/2;
			long p = endK[k]+1+(k+1)*(m-ten[k]);
//			System.out.println("M:"+m+" p:"+p);
			if(p<=x&&x<p+k+1){
				String s = m+"";
				for(int i=0;i<s.length();i++)if(p+i==x)return s.charAt(i)-'0';
			}
			else if(x < p)R=m;
			else L=m;
		}
	}
//	void calc_maxnum(){
//		init();
//		long L = ten[16], R = L*10;
//		while(R-L>1){
//			long m = (R+L)/2;
//			long p = endK[16]+1 + 17*(m-ten[16]);
//			System.out.println("M:"+m+" P:"+p);
//			if(p<=DIGIT_LIMIT && DIGIT_LIMIT<p+17){
//				System.out.println("M:"+m);
//				break;
//			}
//			if(DIGIT_LIMIT < p)R=m;
//			else L=m;
//		}
//	}
	void test(){
		init();
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt(), k = sc.nextInt();
			if((n|k)==0)break;
		for(int i=0;i<k;i++){
//			System.out.println("pos:"+(n+i));
			System.out.print(at(n+i));
		}
		System.out.println();
		}
	}
	
	public static void main(String[] args) {
		new Main().test();
	}
}

Measured memory_bytes: 12000
#include <iostream>
using namespace std ;
int main (){
	int a, b ;
	cin >> a ;
	cin >> b;
	
	if ( a < b ) {
		cout << "a < b" << endl ;
	}else if ( a > b ) {
		cout << "a > b" << endl ;
	}else {
		cout << "a == b" << endl ;
	}
}


Measured memory_bytes: 3056
N = int(input())
A = []
x = [[] for i in range(N)]
y = [[] for i in range(N)]
for i in range(N):
    A.append(int(input()))
    for j in range(A[i]):
        tmpX, tmpY = map(int, input().split())
        x[i].append(tmpX-1)
        y[i].append(tmpY)
ans = 0

for case in range(2**N):
    flag = True
    case = str(format(case, '016b'))[-N:]
    honest = [i for i, x in enumerate(case) if x == '1']
    #print(honest)
    for hon in honest:
        for j, other in enumerate(x[hon]):
            #print(other in honest)
            if (other in honest) and (y[hon][j] == 0):
                flag = False

            elif (not(other in honest)) and (y[hon][j] == 1):
                flag = False

            else:
                continue
    #print(flag)
    if flag:
        ans = max(ans, len(honest))

print(ans)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod=int(1e9+7);

ll dp[1000002];
ll rec(int n)
{	if(n==0) return 1;
	if(n<3) return 0;
	//cout<<n<<endl;
	if(dp[n]!=-1) return dp[n];

	ll count=0;
	for(int i=3;i<=n;i++)
		count=((count%mod)+(rec(n-i)%mod))%mod;

	dp[n]=count;

	return dp[n];
}

int main()
{
	memset(dp,-1,sizeof(dp));
	int n;
	cin>>n;
	cout<<rec(n)<<endl;	
}

Measured memory_bytes: 11460
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(void) {

	char c;
	cin >> c;

	if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
		cout << "vowel" << endl;
	}

	else {
		cout << "consonant" << endl;
	}



}



Measured memory_bytes: 3048
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int N;
string S1, S2;

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

    cin >> N;
    cin >> S1 >> S2;

    ll ans = 1;
    int n = 0;
    int prev;
    if(S1[0] == S2[0]){
        ans = 3;
        prev = 1;
        ++n;
    }
    else {
        ans = 6;
        prev = 2;
        n += 2;
    }
    while(n < N){
        if(S1[n] == S2[n]){
            if(prev == 1){
                ans *= 2;
            }
            prev = 1;
            ++n;
        }
        else {
            if(prev == 1){
                ans *= 2;
            }
            else {
                ans *= 3;
            }
            prev = 2;
            n += 2;
        }
        ans %= mod;
        //cout << ans << endl;
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
    int w=0,s=0,e=0,n=0;
    char S[1000];
    scanf("%s", S);
    int len = strlen(S);
    for (int i = 0; i < len; i++) {
        switch (S[i]) {
            case 'N':
                n++;
                break;
            case 'S':
                s++;
                break;
            case 'E':
                e++;
                break;
            case 'W':
                w++;
                break;
        }
    }
    printf("%s\n", (!n&&s)||(!s&&n)||(!e&&w)||(!w&&e)?"No":"Yes");
}


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

int main(){ 
    int n,m;
    cin >> n>>m;
    vector<pair<int,int>>a;
    for(int i=0;i<n;i++){
        int x,y;
        cin >> x >> y;
        swap(y,x);
        a.push_back(make_pair(y,x));
    }
    long long ans =0,e,f;
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++){
        tie(e,f) = a[i];
        
        if(m >= f){
            ans += f*e;
            m -= f;
        }
        else{
            ans += e*m;
            m = 0;
        }
        if(m == 0)break;
    }
    cout << ans << endl;

 }

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define ll long long
#define pb emplace_back
#define mr make_pair
#define N 187
using namespace std;
int m,n,a[N][N],dp[N][N][N][18];
int ch(int l1,int r1,int l2,int r2){
	int x=a[l2][r2]+a[l1-1][r1-1]-a[l2][r1-1]-a[l1-1][r2];
	if (x==0||x==(l2-l1+1)*(r2-r1+1))return 1;return 0;
}
int main(){
	cin>>n>>m;
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			char ch=getchar();
			while (ch!='.'&&ch!='#')ch=getchar();
			a[i][j]=(ch=='.');
		}
	}
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)a[i][j]+=a[i][j-1];
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)a[i][j]+=a[i-1][j];
	for (int l=1;l<=n;l++){
		for (int r=l;r<=n;r++){
			for (int l1=1;l1<=m;l1++){
				int L=l1-1,R=m,mid;
				while (L<R){mid=(L+R+1)/2;if (ch(l,l1,r,mid))L=mid;else R=mid-1;}
				dp[l][r][l1][0]=L;
			}
		}
	}
	for (int an=1;an<=16;an++){
		for (int le=1;le<=n;le++){
			for (int l=1;l+le-1<=n;l++){
				for (int l1=1;l1<=m;l1++){
					dp[l][l+le-1][l1][an]=dp[l][l+le-1][min(m,dp[l][l+le-1][l1][an-1]+1)][an-1];
					int L=l,R=l+le-1,mid;
					while (L<R){mid=(L+R)/2;if (dp[l][mid][l1][an-1]>dp[mid+1][l+le-1][l1][an-1])L=mid+1;else R=mid;}
					dp[l][l+le-1][l1][an]=max(dp[l][l+le-1][l1][an],
					max(min(dp[l][L-1][l1][an-1],dp[L][l+le-1][l1][an-1]),
					min(dp[l][L][l1][an-1],dp[L+1][l+le-1][l1][an-1])));
				}
			}
		}
	}
	for (int an=0;an<=16;an++){
		if (dp[1][n][1][an]==m){cout<<an<<endl;return 0;}
	}
	return 0;
}

Measured memory_bytes: 450944
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

int N, a, K;

int main() {
    scanf("%d%d", &N, &K);
    vector<ll> t(N);
    for (int i = 0; i < N; i++) scanf("%d", &t[i]);
    a = t[N - 1] + 1 - t[0];
    vector<int> v;
    for (int i = 1; i < N; i++) {
        if (t[i - 1] + 1 != t[i]) v.push_back(t[i] - t[i - 1] - 1);
    }
    sort(v.rbegin(), v.rend());
    for (int i = 0; i < min(K - 1, (int)v.size()); i++) a -= v[i];
    printf("%d\n", a);
}



Measured memory_bytes: 4348
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;

template <class T> using V = vector<T>;

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

const long long INF = 1LL << 60;

using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;



#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);




ll Sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}



const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


#define comuse Comuse()

ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}


ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}


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

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}



/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
//segtreeの葉の先頭の添え字はn-1
void Solve(){
  //ll N=262144;
  //vll segtree(2*N-1);
  st s;
    cin>>s;
  ll ans=0;
  REV(s);
  ll count=0;
  FOR(i,0,s.sz){
    if(s[i]=='W'){
      count++;
    }
    else{
      ans+=count;
    }
  }

  cout<<ans<<"\n";
}

Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

int main(){
	
	
	int s,w;
	cin >> s >>  w;
	if (w>= s){
		cout << "unsafe";
	}
	else{;
		cout << "safe";
	}
	
	
	
	return 0;
	
	
	
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main(void){
  int x,y;
  while(true){
   cin>>x;
   cin>>y;
   if(x==0&&y==0){
      break;
   }
   if(x<y){
      cout<<x<<" "<<y<<endl;
   }
   else{
        cout<<y<<" "<<x<<endl;
    }

  }
}



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

struct ki {
  ll num, kyori;
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<vector<ki>> node(n);
  for (ll i = 0; i < n - 1; i++) {
    ki temp;
    ll a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    temp.num = b;
    temp.kyori = c;
    node[a].push_back(temp);
    temp.num = a;
    temp.kyori = c;
    node[b].push_back(temp);
  }
  ll q, k;
  cin >> q >> k;
  k--;
  // bfs
  queue<ll> que;
  vector<ll> dist(n, 0);
  que.push(k);
  while (!que.empty()) {
    ll temp = que.front();
    que.pop();
    for (ll i = 0; i < node[temp].size(); i++) {
      if (dist[node[temp][i].num] == 0) {
        que.push(node[temp][i].num);
        dist[node[temp][i].num] = dist[temp] + node[temp][i].kyori;
      }
    }
  }

  for (ll i = 0; i < q; i++) {
    ll x, y;
    cin>>x>>y;
    x--;
    y--;
    cout << dist[x] + dist[y] << endl;
  }

  /* 
  for (ll i = 0; i < n; i++) {
    prllf("%d = ", i);
    for (ll j = 0; j < node[i].size(); j++) {
      if (j) {
        prllf(" ");
      }
      prllf("%d", node[i][j]);
    }
    prllf("\n");
  }
  for(ll i=0;i<n;i++){
    cout<<dist[i]<<endl;
  }
  */
  return 0;
}

Measured memory_bytes: 11932
#include<iostream>

using namespace std;

const int N = 2e5 + 10;
long long int a[N];
int n;

int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n;
	long long int sum = 0;
	
	for(int i = 0;i < n;i++)
	{
		cin >> a[i];
			
		sum += a[i];
		sum %= 1000000007;
	}
	
	long long ans = 0;
	
	for(int i = 0 ; i < n ; i++)
	{
		sum -= a[i];
		if(sum < 0) sum += 1000000007;
		
		ans += a[i] * sum;
		ans %= 1000000007;
	}
	
	cout << ans << endl;
	
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    rep(i,n) cin >> a[i] >> b[i] >> c[i];
    vector<vector<int>> dp(n+1, vector<int>(3,0));
    rep(i,n){
        dp[i+1][0] = max(dp[i][1]+a[i],dp[i][2]+a[i]);
        dp[i+1][1] = max(dp[i][0]+b[i],dp[i][2]+b[i]);
        dp[i+1][2] = max(dp[i][0]+c[i],dp[i][1]+c[i]); 
    }
    cout << max(dp[n][0],max(dp[n][1],dp[n][2])) << endl;
    return 0;
}

Measured memory_bytes: 6912
(defn get_H_W []
  (->> (clojure.string/split (read-line) #"\s")
    (map #(Integer/parseInt %))))

(defn set_Array [^"[[C" Array H W]
  (dotimes [h H]
    (->> (read-line)
      (char-array W)
      (aset Array h))))

(defn Minesweeper [^"[[C" Array H W]
  (doseq [x (range W)
          y (range H)
          :let [v ^char (aget ^"[C" (aget Array y) x)]
          :when (not= \# v)]
    (->> (for [d-y-x [[-1 -1] [-1 0] [-1 1] [0 -1] [0 1] [1 -1] [1 0] [1 1]]
               :let [[dy dx] (map + (list y x) d-y-x)]
               :when (and
                       (<= 0 dx)
                       (< dx W)
                       (<= 0 dy)
                       (< dy H)
                       (= \#  (aget ^"[C" (aget Array dy) dx)))]
           true)
      count
      (unchecked-add-int (unchecked-int \0))
      unchecked-char
      (aset ^"[C" (aget Array y) x))))

(defn output [^"[[C" Array]
  (-> (areduce Array idx ret ""
        (str ret
          (apply str (aget Array idx))
          "\n"))
    print))

(let [[H W] (get_H_W)]
  (doto (make-array Character/TYPE H W)
    (set_Array H W)
    (Minesweeper H W)
    (output)))


Measured memory_bytes: 73360
#include <stdio.h>
#include <math.h>

int main(void) {
    double a, b, C, rad;
    double S, L, h;

    scanf("%lf %lf %lf", &a, &b, &C);
    rad = C*(M_PI/180.0);
    S = (1.0/2)*a*b*sin(rad);
    L = a + b + sqrt(a*a + b*b - 2*a*b*cos(rad));
    h = 2*S/a;
    printf("%f\n", S);
    printf("%f\n", L);
    printf("%f\n", h);

    return 0;
}

Measured memory_bytes: 648
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int a,b;
		cin>>a>>b;
		sum+=b-a+1;
	}
	cout<<sum<<"\n";
	return 0;
}

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

using namespace std;

const int maxn = 2050;

vector<int> E[maxn];

int dfs(int x, int p, int d, int mx){
    int ans = 1;
    if(d != mx){
        for(int y : E[x]){
            if(y == p) continue;
            ans += dfs(y, x, d + 1, mx);
        }
    }
    return ans;
}
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i = 0; i < n - 1; i++){
        int a, b; 
        scanf("%d%d",&a,&b);
        E[a].push_back(b);
        E[b].push_back(a);
    }
    int ans = 0;
    if(k % 2 == 0){
        for(int v = 1; v <= n; v++){
            ans = max(ans, dfs(v, -1, 0, k / 2 ));
        }
    }else{
        for(int v = 1; v <= n; v++){
            for(int u : E[v]){
                ans = max(ans, dfs(v, u, 0, k / 2) + dfs(u, v, 0, k / 2));
            }
        }
    }
    ans = n - ans;
    printf("%d\n", ans);
}

Measured memory_bytes: 512
#include <cstdio>
#include <unordered_set>

int main() {
  int n;
  scanf("%d", &n);
  int xor_sum = 0;
  std::unordered_set<int> s;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    xor_sum ^= x;
    s.insert(x ^ (x - 1));
  }

  int ans = 0;
  for (int bit = 29; bit >= 0; bit--) {
    if (((1 << bit) & xor_sum) == 0) {
      continue;
    }
    int x = (1 << (bit + 1)) - 1;

    if (s.find(x) != s.end()) {
      xor_sum ^= x;
      ans += 1;
    }
  }

  if (xor_sum != 0) {
    printf("-1\n");
  } else {
    printf("%d\n", ans);
  }
}

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

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var n = sc.nextInt();
		var m = sc.nextInt();
		var q = sc.nextInt();
		var a = new int[q];
		var b = new int[q];
		var c = new int[q];
		var d = new int[q];
		for (var i = 0; i < q; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}
		sc.close();

		var maxpoint = 0;
		List<String> list = new ArrayList<String>();
		create(n, m, "", list);
		for (var text : list) {
			var point = 0;
			for (var i = 0; i < q; i++) {
				int an = Integer.parseInt(text.substring(a[i] - 1, a[i]));
				int bn = Integer.parseInt(text.substring(b[i] - 1, b[i]));
				if (bn - an == c[i]) {
					point += d[i];
				}
			}
			maxpoint = Math.max(maxpoint, point);
		}
		System.out.println(maxpoint);
	}

	public static void create(int n, int m, String text, List<String> texts) {
		if (text.length() == n) {
			texts.add(text);
			return;
		}

		var s = 0;
		if (text.length() > 0) {
			s = Integer.parseInt(text.substring(text.length() - 1, text.length()));
		}

		for (int i = s; i < m; i++) {
			create(n, m, text + i, texts);
		}
	}
}

Measured memory_bytes: 65752
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;

class Solver {
    Scanner sc = new Scanner();

    public void Solve() {
        var S = ReadLine();

        if (S.ToCharArray().Distinct().Count() == 26) {
            WriteLine("None");
            return;
        }

        var a = "abcdefghijklmnopqrstuvwxyz";
        WriteLine(a.ToCharArray().Except(S.Distinct()).First());
    }


}



class Scanner {
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt() {


        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble() {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0) {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++) {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Program {
    static void Main(string[] args) {
        Solver s = new Solver();
        s.Solve();
    }
}

Measured memory_bytes: 13920
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

using ld=long double;


int main() {	
	int N;cin>>N;
	vector<vector<pair<int,int>>>times(N,vector<pair<int,int>>(3));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 3; ++j) {
			int h,m;cin>>h>>m;
			times[i][j].first=h*60+m;

			int h2,m2;cin>>h2>>m2;
			times[i][j].second=h2*60+m2;
		}
	}
	int ans=0;
	for (int mo = 0; mo < 1440; ++mo) {
		for (int lu = mo + 1; lu < 1440; ++lu) {
			map<int,int>mp;
			for (int i = 0; i < N; ++i) {
				bool valid=true;
				if(mo<times[i][0].first||times[i][0].second<mo)valid=false;
				if(lu<times[i][1].first||times[i][1].second<lu)valid=false;

				if (valid) {
					mp[times[i][2].first]++;
					mp[times[i][2].second+1]--;
				}
			}
			int num=0;
			for (auto m : mp) {
				num+=m.second;
				ans=max(ans,num);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int n,m;
set<int>q;
int dis(int x1,int y1,int x2,int y2)
{
    return abs(x1-x2)+abs(y1-y2);
}
int a1[10000],b1[100000],a2[10000],b2[100000];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>a1[i]>>b1[i];
    }
    for(int i=1;i<=m;i++)
    {
        cin>>a2[i]>>b2[i];
    }
    for(int i=1;i<=n;i++)
    {
        int pos;
        int Max=(1<<31)-1;
        for(int j=1;j<=m;j++)
        {
            int ans=dis(a1[i],b1[i],a2[j],b2[j]);
            //cout<<ans<<endl;
            if(ans<Max)
            {
                pos=j;
               // cout<<pos<<endl;
                Max=ans;
            }
        }
        cout<<pos<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid  + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k=left; k<right; k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if(p<r) {
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for(i=0;i<n;i++) {
    scanf("%s %d",S,&v);
    A[i].suit =  B[i].suit  = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++) {
    // マージソートとクイックソートの結果を比べる
    if(A[i].suit != B[i].suit) stable = 0;
  }

  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}


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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

int dp[100005][3], v[100005][3], n;
bool mark[100005][3];

int f(int i, int j) {
	if(i == n) return 0;
	if(mark[i][j]) return dp[i][j];
	mark[i][j] = true;

	int ret = 0;

	for(int k = 0; k < 3; k++) {
		if(i == 0 or k != j)
			ret = max(ret, f(i+1, k) + v[i][k]);
	}

	return dp[i][j] = ret;
}

int main() {
	scanf("%d", &n);

	for(int i = 0; i < n; i++)
		for(int j = 0; j < 3; j++)
			scanf("%d", &v[i][j]);
	printf("%d\n", f(0,0));
    
    return 0;
}

Measured memory_bytes: 10752
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
  Scanner sc;

  class Point {
    int x;
    int y;

    Point(int x, int y) {
      this.x = x;
      this.y = y;
    }

    public String toString() {
      return "(" + x + ", " + y + ")";
    }
  }

  int INF = 1 << 28;

  void run() {
    for ( ;; ) {
      int x = ni();
      int y = ni();

      if ( ( x | y ) == 0 ) {
        break;
      }

      Point S = null;
      Point G = null;
      ArrayList<ArrayList<Point>> list = new ArrayList<ArrayList<Point>>();
      for ( int i = 0; i < 5; ++i ) {
        list.add( new ArrayList<Point>() );
      }
      for ( int i = 0; i < y; ++i ) {
        char[] str = sc.next().toCharArray();
        for ( int j = 0; j < x; ++j ) {
          if ( str[ j ] == 'S' ) {
            S = new Point( j, i );
          } else if ( str[ j ] == 'G' ) {
            G = new Point( j, i );
          } else if ( str[ j ] == '.' ) {
          } else {
            int id = str[ j ] - '0' - 1;
            ArrayList<Point> subl = list.get( id );
            subl.add( new Point( j, i ) );
          }
        }
      }

      int ansid = INF;
      int min = INF;
      int[][] dp = new int[5][1001];
      for ( int i = 0; i < 5; ++i ) {
        for ( int j = 0; j < list.get( ( i + 1 ) % 5 ).size(); ++j ) {
          dp[ ( i + 1 ) % 5 ][ j ] = dist( S, list.get( ( i + 1 ) % 5 ).get( j ) );
        }
        for ( int j = 2; j < 5; ++j ) {
          int nidx = ( i + j ) % 5;
          int prev = ( nidx + 4 ) % 5;
          for ( int k = 0; k < list.get( nidx ).size(); ++k ) {
            dp[ nidx ][ k ] = INF;
          }
          for ( int k = 0; k < list.get( nidx ).size(); ++k ) {
            for ( int l = 0; l < list.get( prev ).size(); ++l ) {
              dp[ nidx ][ k ] = Math
                  .min(
                      dp[ nidx ][ k ],
                      dp[ prev ][ l ]
                          + dist( list.get( nidx ).get( k ), list.get( prev )
                              .get( l ) ) );
            }
          }
        }
        int subm = INF;
        for ( int j = 0; j < list.get( ( i + 4 ) % 5 ).size(); ++j ) {
          subm = Math.min(
              subm,
              dp[ ( i + 4 ) % 5 ][ j ]
                  + dist( list.get( ( i + 4 ) % 5 ).get( j ), G ) );
        }
        if ( min > subm ) {
          min = subm;
          ansid = i + 1;
        }
      }

      if ( min == INF ) {
        System.out.println( "NA" );
      } else {
        System.out.println( ansid + " " + min );
      }
    }
  }

  int dist(Point a, Point b) {
    return Math.abs( a.x - b.x ) + Math.abs( a.y - b.y );
  }

  Main() {
    sc = new Scanner( System.in );
  }

  int ni() {
    return sc.nextInt();
  }

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

  void debug(Object... os) {
    System.err.println( Arrays.deepToString( os ) );
  }
}

Measured memory_bytes: 76260
a, b, c, d = map(int, input().split())

x_cands = [a, b]
if a <= 0 <= b:
	x_cands.append(0)
y_cands = [c, d]
if c <= 0 <= d:
	y_cands.append(0)

values = []
for x in x_cands:
	for y in y_cands:
		values.append(x * y)

print(max(values))


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

int main(){
    int n,l,ans=0;
    cin>>n>>l;
    if(l>=0){
        ans=(2*l+n)*(n-1)/2;
    }
    else if(l+n-1>=0){
        ans=(2*l+n-1)*n/2;
    }
    else{
        ans=(2*l+n-2)*(n-1)/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Queue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		List<List<Integer>> card = new ArrayList<>();

		for(int i = 0 ; i < N ; i++){
			card.add(new ArrayList<>());
		}

		for(int i = 0 ; i < M ; ++i){
			int u = sc.nextInt()-1;
			int v = sc.nextInt()-1;
			int w = sc.nextInt();

			card.get(u).add(v);
			card.get(v).add(u);
		}

		sc.close();

		int ans = 0;
		boolean[] magic = new boolean[N+1];
		Arrays.fill(magic, false);

		for(int i = 0 ; i <  N ; i++){
			if(magic[i]){
				continue;//チェック済
			}

			magic[i] = true;
			ans ++;

			Queue<Integer> queue = new ArrayDeque<>();
			//未チェックのものをqueue.add
				queue.add(i);
			while(!queue.isEmpty()){
				int tmp = queue.poll();

					//pollした値とペアになっている数値をすべて確認

				for(int k = 0 ;k<card.get(tmp).size();k++){
					int tmp2 = card.get(tmp).get(k);
						if(magic[tmp2]){
							continue;
						}
				//つながっていればtrue
				magic[tmp2] = true;
				queue.add(tmp2);
				}
			}
		}
		System.out.println(ans);
	}
}


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

struct UF{
	vector<int> p;
	UF() {}
	UF(int n) : p(n, -1) {}
	int find(int a){ return p[a] < 0 ? a : p[a] = find(p[a]); }
	bool unite(int a, int b) {
		a = find(a); b = find(b);
		if(a == b) return false; 
		if(-p[a] < -p[b]) swap(a, b);
		p[a] += p[b]; p[b] = a;
		return true;
	}
	bool root(int a){ return p[a] < 0; }
	bool same(int a, int b){ return find(a) == find(b); }
	int size(int a){ return -p[find(a)]; }
};

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >>n >>k;
	VI d(10);
	rep(i, k){
	 int z; cin >>z; d[z] = 1;
	}
	
	
	rep2(i, n, 1111*n){
		bool ok = true;
		for(int w=i; w>0; w/=10) if(d[w%10]==1) ok=false;
		if(ok){
			cout << i <<"\n"; return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll i=0; i<N; i++)
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll N_MAX = 100000;

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

    stack<ll> stk;
    stk.push(s[0]);
    for(ll i = 1; i < n; i++){
        if(stk.top() == s[i]){
            continue;
        }else{
            stk.push(s[i]);
        }
    }
    cout << stk.size() << endl;
}

Measured memory_bytes: 1152
s = str(input())

if len(s) == 2:
    if s[0] ==s[1]:
        start_ind =1
        end_ind = 2
    else:
        start_ind = -1
        end_ind = -1
        
elif len(s)>2:
    start_ind = -1
    end_ind = -1
    for i in range(len(s)-2):
        par_str = s[i:i+3]
        if (par_str.count(par_str[0])>=2) | (par_str.count(par_str[1])>=2):
            start_ind = i + 1
            end_ind = i + 3
            break
        
        

ans = str(start_ind) + ' ' + str(end_ind)

print(ans)


Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = int.Parse(Console.ReadLine().Replace(" ", string.Empty));
            for (int i = 1; i <= 1000; i++)
            {
                if (r == i * i)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
        }
    }
}

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

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

    int R, C, K;
    cin >> R >> C >> K;
    vector<vector<vector<ll>>> dp(R+1, vector<vector<ll>>(C+1, vector<ll>(4)));
    vector<vector<int>> items(R+1, vector<int>(C+1));
    for (int i = 0; i < K; i++) {
        int r, c, v;
        cin >> r >> c >> v;
        items[r][c] = v;
    }
    for (int i = 1; i <= R; i++) {
        for (int j = 1; j <= C; j++) {
            for (int k = 0; k < 4; k++) {
                dp[i][j][0] = max(dp[i][j][0], dp[i-1][j][k]);
                if (items[i][j]) {
                    dp[i][j][1] = max(dp[i][j][1], dp[i-1][j][k] + items[i][j]);
                }
                dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k]);
                if (items[i][j] && k) {
                    dp[i][j][k] = max(dp[i][j][k], dp[i][j-1][k-1] + items[i][j]);
                }
            }
        }
    }
    ll ans = *max_element(dp[R][C].begin(), dp[R][C].end());
    cout << ans << endl;
}


Measured memory_bytes: 671368
#include <algorithm>
#include <cstddef>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

// Precomputer the number of layers and patties at each level
auto getLayers(uint64_t N) {
    vector<pair<uint64_t,uint64_t>> output = {{1ull,1ull}};
    while (N > 0) {
        auto last = output.back();
        auto layers = 2*last.first + 3;
        auto patties = 2*last.second + 1;
        output.push_back(make_pair(layers, patties));
        N--;
    }
    return output;
}

// Consumes up to numLayers from a burger of given level
pair<uint64_t,uint64_t> consumeBurger(uint64_t level, uint64_t numLayers, const vector<pair<uint64_t,uint64_t>>& levelCounts) {
    if (numLayers >= levelCounts[level].first) {
        // All layers are edible
        return levelCounts[level];
    } else if (numLayers > 1 + levelCounts[level - 1].first) {
        // We can only eat somewhere inside the second sub-burger
        const auto preLayers = 1 + levelCounts[level - 1].first + 1;
        const auto prePatties = levelCounts[level - 1].second + 1;
        auto next = consumeBurger(level - 1, numLayers - preLayers, levelCounts);
        return make_pair(preLayers + next.first, prePatties + next.second);
    } else if (numLayers > 1) {
        // We can only eat somewhere inside the first sub-burger
        auto next = consumeBurger(level - 1, numLayers - 1, levelCounts);
        return make_pair(next.first + 1, next.second);
    } else {
        // There are no edible patties
        return make_pair(numLayers, 0ull);
    }
}    

auto solve(uint64_t N, uint64_t X) {
    const auto layers = getLayers(N);
    return consumeBurger(N, X, layers).second;
}

// Read parameters from standard input and call main solution function
int main() {
    uint64_t N, X;
    cin >> N >> X;
    cout << solve(N, X) << endl;
    return 0;
}

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

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)
// int ncr(int n,int r) {return (fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod;}
// int modInv(int i) {return binExp(i,mod-2);}

int dp[3001][3001];

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    // test
    {
        int n;
        cin>>n;

        f1(i,0,n)f1(j,0,n) dp[i][j] = 0;

        int a[n];
        f0(i,0,n) cin>>a[i];
        f0(i,0,n) dp[i][i] = a[i];

        f3(i,n-1,0)
        {
            f0(j,i+1,n)
            {
                dp[i][j] = max(a[i] - dp[i+1][j], a[j] - dp[i][j-1]);

            }
        }
        cout<<dp[0][n-1];
    }
}

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

int main() {
  int K; cin >> K;  // 判定回数
  queue<int64_t> que; // ルンルン数を下から入れているキュー
  int C=0;  // カウント
  int64_t num1,num2;
  // １桁の数値は全てルンルン数
  rep(i,9){
    num1 = i+1;
    if(K==++C){ cout << num1 << endl; return 0; }
    que.push(num1);
  }

  int64_t Y;  // ;剰余用
  while (C<K){    // カウントして抜ける。
    num2 = que.front();que.pop();   // que の先頭を取得
    Y = num2%10;

    // －１のルンルン数
    if(Y!=0){ 
      num1 = num2*10 + Y - 1;
      if(K==++C){ cout << num1 << endl; return 0; }
      que.push(num1);
    }
    // そのまま同じルンルン数
    num1 = num2*10 + Y;
    if(K==++C){ cout << num1 << endl; return 0; }
    que.push(num1);
    // ＋１のルンルン数
    if(Y!=9){ 
      num1 = num2*10 + Y + 1;
      if(K==++C){ cout << num1 << endl; return 0; }
      que.push(num1);
    }
  }

}


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

using namespace std;

int main(){
  int N,K,M;

  while(cin >> N >> K >> M, (N | K | M)){
    vector<int> vec;
    for(int i = 0 ; i < N ; i++){
      vec.push_back(i+1);
    }
    vec.erase(vec.begin()+M-1);
    int cur = (K + M - 2) % vec.size();
    while(true){
      if(vec.size() == 1) break;
      vec.erase(vec.begin()+cur);
      cur = (cur + K - 1) % vec.size();
    }
    cout << vec[0] << endl;
  }

  return 0;
}

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

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	const int MAX = 100 * 100 + 100;
	int N;
	int maximum = 0;
	vector<int> s, hoge;
	
	cin>>N;
	
	s.resize(N);
	hoge.resize(MAX);
	
	hoge[0] = true;
	
	for(int i = 0; i < N; i++){
		cin>>s[i];
		
		for(int j = MAX-1; j >= 0; j--){
			if(hoge[j]){
				hoge[j + s[i]] = true;
			}
		}
	}
	
	for(int i = 0; i < MAX; i++){
		if(i%10 == 0) continue;
		if(hoge[i]) maximum = max(maximum, i);
	}
	
	cout<<maximum<<endl;
	
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int d[50];
  int sum=0;
  rep(i,n){
    cin>>d[i];
    sum+=d[i];
  }
  int ans=0;
  rep(i,n){
    ans+=d[i]*(sum-d[i]);
  }
  cout<<ans/2<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359


int main(){
    iostream::sync_with_stdio(false);
    
	int A,B,C;
	cin >> A >> B >> C;
	int tmp = 0;
	for(int i=1; i<INT_MAX; i++){
		tmp += A;
		if(i%7 == 0) tmp += B;
		if(tmp >= C){
			cout << i << endl;
			return 0;
		}
	}
    
    return 0;
}



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

int main(){
    int x, y;
    cin >> x >> y;
    if (x < y) {
        swap(x, y);
    }
    while (x % y) {
        int a = x;
        x = y;
        y = a % y;
    }
    cout << y << endl;
}



Measured memory_bytes: 3116
S=str(input())
N=len(S)
now="R"
stock=0
num_list=[]
prev=0
S+="E"
for i in range(0,N+1):
    if(now=="R"):
        if(S[i]=="R"):
            stock+=1
            num_list.append(0)
        else:
            num_list.append(0)
            num_list[i]+=(stock//2)
            num_list[i-1]+=((stock+1)//2)
            now="L"
            prev=i
            stock=1
    elif(now=="L"):
        if(S[i]=="L"):
            stock+=1
            num_list.append(0)
        elif(S[i]=="R"):
            num_list.append(0)
            num_list[prev]+=((stock+1)//2)
            num_list[prev-1]+=(stock//2)
            now="R"
            stock=1
        elif(S[i]=="E"):
            num_list[prev]+=((stock+1)//2)
            num_list[prev-1]+=(stock//2)
for i in range(0,N):
    print(num_list[i],end=" ")

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

int main()
{
	long get ;
	int sum = 0 ;
	while( cin >> get )
	{
		if( get == 0 ) break ;

		int tmp = 0 ;
		for( int i = 5 ; i <= get ; i *= 5 )
		{
			tmp = get%i ;
			sum += ((get-tmp)/i) ;
		}
		cout << sum << endl ;
		sum = 0 ;
	}

	return 0 ;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int in;
  set<int> arr;
  for(int i = 0;i < n;i++)
  {
    int d;
    cin>>d;
    for(int i = 0;i < d;i++)
    {
      cin>>in;
      arr.insert(in);
    }
  }
  cout<<n - arr.size();
  return 0;
}


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

""" HonestOrDishonest """

def main():
    a, b = input().split()

    honest = 0
    if a == 'D':
        honest += 1
    if b == 'D':
        honest += 1

    if  honest == 1:
        print('D')
    else:
        print('H')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

const int MAX_N = 15;
const int MAX_W = 110000;

int dp[MAX_N][MAX_W];

int main(){
    int w; cin >> w;
    vector<int> weight;
    for(int i = 1; i <= w; i *= 6) weight.push_back(i);
    for(int i = 9; i <= w; i *= 9) weight.push_back(i);
    int n = (int)weight.size();
    for(int i = 0; i < MAX_N; ++i)for(int j = 0; j < MAX_W; ++j) dp[i][j] = 1 << 29;
    for(int i = 0; i <= n; ++i) dp[i][0] = 0;

    for(int i = 0; i < n; i++){
        for(int j = 0; j <= w; j++){
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            if(j >= weight[i]) dp[i+1][j] = min(dp[i+1][j], dp[i+1][j-weight[i]] + 1);
        }
    }
    cout << dp[n][w] << endl;
}

Measured memory_bytes: 6656