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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,M;
ll X[3][1111], Y[3][1111], Z[3][1111];
ll i, j, k;

ll ans;

void mxin(ll& a,ll b){
    if(a<b)
        a = b;
}


ll calc(ll* x,ll* y,ll* z){
    ll i, j;
    vector<ll> vv;
    fornum(i,0,N){
        vv.push_back(x[i] + y[i] + z[i]);
    }
    sort(vv.begin(), vv.end());
    ll a = 0;
    fornum(i,0,M){
        a += vv[N - 1 - i];
    }
    return a;
}


int main(){
    scanf("%lld%lld",  &N,&M);

    fornum(i,0,N){
        scanf("%lld%lld%lld", &X[0][i], &Y[0][i], &Z[0][i]);
        X[1][i] = -X[0][i];
        Y[1][i] = -Y[0][i];
        Z[1][i] = -Z[0][i];
    }
    fornum(i,0,8){
        mxin(ans, calc(X[(i & 1) == 0], Y[(i & 2) == 0], Z[(i & 4) == 0]));
    }

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


Measured memory_bytes: 384
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
string s;
int len,ans;
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>s;
	len=s.length();
	for(int i=0;i<len;++i)
	{
		if('A'<=s[i]&&s[i]<='Z')
		{
			s[i]=s[i]-'A'+'a';
		}
	}
	for(int i=0;i<len>>1;++i)
	{
		if(s[i]!=s[len-1-i])
		{
			++ans;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

fun main(args: Array<String>) {
    val (A, B, C, K) = readStrings().map { it.toLong() }
    println((A - B) * (if (K % 2L == 0L) 1 else -1))
}

Measured memory_bytes: 38032
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define REP(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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, D;
    cin >> H >> W >> D;
    vector< vector<int> > A(H, vector<int>(W));
    pair<int, int> P[H*W+1];
    rep(i, H) {
        rep(j, W) {
            cin >> A[i][j];
            P[A[i][j]].first  = i;
            P[A[i][j]].second = j;
        }
    }
    vector<int> sum(H*W+2);
    REP(i, D+1, H*W) {
        sum[i] = sum[i-D] + abs(P[i].first - P[i-D].first) + abs(P[i].second - P[i-D].second);
    }
    int Q; cin >> Q;

    rep(i, Q) {
        int s, t; cin >> s >> t;
        cout << sum[t] - sum[s] << endl;
    }


    return 0;
}


Measured memory_bytes: 2560
import java.io.*;

class Card {
	char suit;
	int value;
	int order;
	
	public Card( char suit, int value, int order )
	{
		this.suit = suit;
		this.value = value;
		this.order = order;
	
		return;
	}
}

class Main {
	
    public static void main(String[] args) {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {
            int n = Integer.parseInt( kb.readLine() );
			String[] nums = kb.readLine().split( " " );
			Card[] cards = new Card[n];
            int i, j;
            
            for( i=0; i<n; i++ ) {
            	cards[i] = new Card( nums[i].charAt( 0 ) , Integer.parseInt( nums[i].substring( 1, 2 ) ), i );
            }
			Card[] savecards = cards.clone();
			Card[] clonecards = cards.clone();
			
			bubbleSort( cards );
			
            StringBuilder output = new StringBuilder( 200+1 );
            for( i=0; i<n; i++ ) {
            	output.append( cards[i].suit  );
            	output.append( cards[i].value  );
            	output.append( " "  );
            }
            output.deleteCharAt( output.lastIndexOf( " " ) );
            System.out.println( output );
            System.out.println( "Stable" );
            

			selectionSort( clonecards );
			
           output.setLength( 0 ); 
           for( i=0; i<n; i++ ) {
            	output.append( clonecards[i].suit  );
            	output.append( clonecards[i].value  );
            	output.append( " "  );
            }
            output.deleteCharAt( output.lastIndexOf( " " ) );

            System.out.println( output );
            
            boolean istable = true;
           for( i=0; i<n && istable; i++ ) {
	           for( j=0; j<n; j++ ) {
	            	if( savecards[i].value == clonecards[j].value ) {
	            		if( clonecards[j].order == savecards[i].order   ) {
	            			break;
	            		} else if( savecards[i].order < clonecards[j].order ) {
	            			istable = false;
	            			break;
	            		}
	            	}
            	}
            }
            
            if( istable ) {
            	System.out.println( "Stable" );
            } else {
            	System.out.println( "Not stable" );
            }
	 
            kb.close();
        } catch( IOException e ) {
            System.err.println( e );
        }        
    }
    static void bubbleSort( Card[] A ) 
    {
        Card tmp;
        int i, j;
        int n = A.length;

        for( i=0; i<n; i++ ) {
            for( j=n-1; i<j; j-- ) {
                if( A[j].value < A[ j-1 ].value ) {
                    tmp = A[ j-1 ];
                    A[ j-1 ] = A[ j ];
                    A[ j ] = tmp;
                }
            }
        }
        return;
    }    
    static void selectionSort( Card[] A ) 
    {
    	Card tmp;
    	int i, j, mini;
    	int n = A.length;

   		for( i=0; i<n; i++ ) {
   			mini = i;
   			for( j=i; j<n; j++ ) {
   				if( A[j].value < A[ mini ].value ) {
   					mini = j;
   				}
   			}
   			if( mini != i ) {
		   		tmp = A[ mini ];
				A[ mini ] = A[ i ];
				A[ i ] = tmp;
			}
   		}
   		return;
    }
}

Measured memory_bytes: 16964
a = int(input())
S =""
l =['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
num = a % 26
while a >0:
    if a%26 !=0:
        S =l[(a%26)-1] + S
        a = (a-a%26)//26
    else:
        S = l[(a%26)-1] + S
        a = (a-26)//26
print(S)



Measured memory_bytes: 9156
#s = input()
n = int(input())
#n,m = map(int,input().split())
lst1 = list(map(int,input().split()))
ans = 10**9
for i in range(1,101):
    res = 0
    for j in lst1:
        res += (j-i)**2
    ans = min(res,ans)

print(ans)

Measured memory_bytes: 38896
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;

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

int main()
{
    ll n,start;
    cin >> n >> start;
    vector<ll> x(n);
    rep(i,n){
        cin >> x[i];
    }
    x.pb(start);
    sort(x.begin(),x.end());
    vector<ll> d(n);
    rep(i,n){
        d[i] = x[i+1]-x[i];
    }
    //MAX GCD
    ll ans = d[0];
    reps(i,1,n){
        ans = gcd(ans,d[i]);
    }
    cout << ans;
}

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

int main()
{
  int n,q;
  cin >> n >> q;
  string s;
  int ans=0;
  cin >> s;
  vector <int> apper={};
  apper.push_back(0);
  //cout <<apper.at(0)<<endl;
  for(int i=0;i<s.size()-1;i++){
    if(s.at(i)=='A' and s.at(i+1)=='C'){
      ans++;
    }
    apper.push_back(ans);
    //cout << apper.at(i+1)<<endl;
  }
  int st,fin;
  for(int i=0;i<q;i++){
  cin >>st>>fin;

 cout << apper.at(fin-1) - apper.at(st-1) << endl;
  }
}



Measured memory_bytes: 1528
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	reader = bufio.NewReader(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
)

func main() {
	defer writer.Flush()
	var N int
	fmt.Fscanf(reader, "%d\n", &N)
	l := make([]int, N)
	r := make([]int, N)
	var count int
	for i := 0; i < N; i++ {
		fmt.Fscanf(reader, "%d %d\n", &l[i], &r[i])
		count += r[i] - l[i] + 1
	}

	fmt.Fprintf(writer, "%d\n", count)
}


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

using namespace std;


int main(int argc, char** argv)
{
    int n, m; cin >> n >> m;
    vector<int> result(m);
    fill(result.begin(), result.end(), 0);
    for (int i = 0; i < n; i++) {
        int k; cin >> k;
        for (int j = 0; j < k; j++) {
            int a; cin >> a;
            result[a-1]++;
        }
    }

    int sum = 0;
    for (auto& ret : result) {
        if (ret == n) sum++;
    }
    cout << sum << endl;
    return 0;
}


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

using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#define pb push_back
#define int long long
#define ld long double
#define ll long long

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << " " << b << " " << c << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class T>
inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>
inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int cnt[110];
signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,K; cin >> N >> K;
    rep(i,K){
        int d; cin >> d;
        rep(j,d){
            int a; cin >> a;
            a--;
            cnt[a]++;
        }
    }
    int ans=0;
    rep(i,N){
        if(cnt[i]==0) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	LL a, b, c, k;
	cin >> a >> b >> c >> k;
	printf("%lld\n", k % 2 == 0 ? a - b : b - a);
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author TM
 */


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cmath>
#include <numeric>
#include <iterator>

#define SIZE 100005
#define MOD 1000000007
#define INF 100000000

using namespace std;

class DDisjointSetOfCommonDivisors {
public:

    void Eratosthenes(const int N) {
        for (int i = 0; i <= N; i++) {
            is_prime[i] = true;//初期化
        }
        for (int i = 2; i <= N; i++) {
            if (is_prime[i]) {
                for (int j = 2 * i; j <= N; j += i) {
                    is_prime[j] = false;
                }
                P.emplace_back(i);
            }
        }
    }

    void solve(std::istream &cin, std::ostream &cout) {
        long a;
        cin >> a;
        Eratosthenes(1000000);
        for (const auto &p : P) {
            if (p >= a) {
                cout << p << endl;
                break;
            }
        }
    }

    bool is_prime[1000000 + 100];
    vector<int> P;
};


int main() {
    DDisjointSetOfCommonDivisors solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

#define fi first
#define se second

const int N = 10010;
const long long mod = 1e9 + 7;

using namespace std;

int n;
int c[N];
int d[N];

int main()
{
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        ios_base::sync_with_stdio(0);

        cin >> n;
        for(int i = 1; i <= n; i++){
                char x;
                cin >> x;
                c[x]++;
        }
        d[0] = 1;
        for(int i = 1; i < N; i++){
                d[i] = (1ll * d[i - 1] * (c[i] + 1)) % mod;
        }
        cout << ((d[N - 1] - 1) % mod + mod) % mod << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif 
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};


int n,m;
int ans;
signed main(){
	
	cin>>n;
    cout<<n*n<<endl;
	

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
    int H, W;

    cin >> H >> W;

    while (H || W)
    {
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if(i == 0 || j == 0 || i == H-1 || j == W-1)
                {
                    cout << '#';
                }
                else
                {
                    cout << '.';
                }
            }
            cout << endl;
        }
        cout << endl;
        cin >> H >> W;
    }

    return 0;
}



Measured memory_bytes: 3020
<?php
fscanf(STDIN, '%s', $n);
$sn = 0;
for($i = 0; $i < strlen($n); $i++) {
    $sn += (int)$n[$i];
}
//echo $sn;
echo ((int)$n % $sn == 0) ? 'Yes' : 'No';
echo "\n";

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

char str[10];
bool query(long long N)
{
	printf("? %lld\n", N);
	fflush(stdout);
	scanf("%s", str);
	return str[0] == 'Y';
}

int a[] = {0,9,99,999,9999,99999,999999,9999999,99999999,999999999};
bool ans[10];
int main()
{
	for (int i = 0; i <= 9; i++) ans[i] = query(a[i]+1);
	if (ans[9] == 1) {
		for (int i = 1; i <= 9; i++)
			if (query(a[i])) {
				printf("! %d\n", a[i-1]+1);
				fflush(stdout);
				return 0;
			}
		printf("! %d\n", a[9]+1);
		fflush(stdout);
		return 0; 
	} else {
		// cerr << "HAHA" << endl;
		int first_dey = 0;
		while (ans[first_dey]) first_dey++;
		int L = a[first_dey-1]+1, R = a[first_dey], Mid;
		// cerr << L << " " << R << endl;
		while (L <= R) {
			// cerr << L << " " << R << endl;
			Mid = (L+R)>>1;
			if (query(Mid*10ll+9)) R = Mid-1;
			else L = Mid+1;
		}
		printf("! %d\n", R+1);
		fflush(stdout);
	}
	return 0;
}


Measured memory_bytes: 680
n = int(input())
a = [105,135,165,189,195]
if n < 105:
    print(0)
elif 105 <= n < 135:
    print(1)
elif 125 <= n < 165:
    print(2)
elif 165 <= n < 189:
    print(3)
elif 189 <= n < 195:
    print(4)
else:
    print(5)

Measured memory_bytes: 3188
N, M = map(int, input().split())

bridges = []
for i in range(M):
	bridges.append(list(map(int, input().split())))

intervals = sorted(bridges, key=lambda x: (x[1], x[0]))

#print(bridges)
count=1
done=[intervals[0]]

for interval in intervals:
	#print(interval)
	if not interval[0] < done[-1][1]:
		count += 1
		done.append(interval)	
#print(done)
print(count) 

Measured memory_bytes: 37564
A,B,C,X,Y = gets.split.map(&:to_i)

x = X
y = Y

cost = 0
if (A+B) >= C*2
  c_num = [X,Y].min
  cost += c_num * C * 2

  x -= c_num
  y -= c_num

  if x!=0 && y==0
    if A <= C * 2
      cost += x * A
    else
      cost += (2 * x * C)
    end
  elsif x==0 &&y!=0
    if B <= C * 2
      cost += y * B
    else
      cost += (2 * y * C)
    end
  end
else
  cost += (A*x) + (B*y)
end
puts cost

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

int main() {
  const int N = 1000000;
  vector<bool> prime(N, true);
  prime[0] = prime[1] = false;
  for (int i = 2; i*i < N; ++i) {
    if (!prime[i]) { continue; }
    for (int j = i*i; j < N; j += i) {
      prime[j] = false;
    }
  }
  vector<int> ans(N);
  for (int i = 1; i < N; ++i) {
    ans[i] = ans[i - 1] + prime[i];
  }
  int n;
  while (cin >> n) {
    cout << ans[n] << endl;
  }
}

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

// main
int main(){
    int N, A; cin >> N >> A;
    int res = N % 500;
    if(res <= A){
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] s = scanner.nextLine().toCharArray();
			char pre = ' ';
			int count = 0;
			for (char c : s) {
				if (c != pre) {
					count++;
					pre = c;
				}
			}
			System.out.println(count - 1);
		}
	}
}


Measured memory_bytes: 26176
#include <bits/stdc++.h>
#define ll long long
#define sz size
#define pb push_back
#define er erase
#define in insert
#define fr first
#define sc second
#define mp make_pair
#define pi pair
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
#define rc(s) return cout<<s,0
const int mod=1e9+7;
const int inf=1e5;
using namespace std;

int n,a;

int main(){
    cin >> n >> a;
    if(n%500<=a)rc("Yes");
    rc("No");

}


Measured memory_bytes: 256
#include<stdio.h>
#define Nn 10000
#define Nq 500

int main(){
  int S[Nn],T[Nq],n,q,i,j,count=0,flag;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }

  for(j=0;j<q;j++){
    i=0;
    S[n]=T[j];
    while(S[i]!=T[j]){
      i++;
    }
    if(i!=n){
      count++;
    }
  }

  printf("%d\n",count);
  return 0;
}
      
  



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

int main(){
  long long int N;
  
  cin >> N;
  
  long long int ans = N + 1;
  for(int i = 1;i <= sqrt(N);i++) if(N % i == 0) ans = min(ans, (N/i + i));
  
  cout << ans - 2 << endl;
  
  return 0;
}

Measured memory_bytes: 3680
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import Counter, defaultdict

def compress(c: list) -> list:
    pre = 0
    ret = []
    for ci in c:
        if ci != pre:
            ret.append(ci)
            
        pre = ci
        
    return ret

def rem_alone(c: list) -> list:
    cnt = Counter(c)
    aln = set()
    for k, v in cnt.items():
        if v == 1:
            aln.add(k)
        
    ret = []
    for ci in c:
        if ci in aln:
            continue
        
        ret.append(ci)
        
    return ret

def find_prev_idx(c: list) -> dict:
    idx = defaultdict(list)
    prev = defaultdict(int)
    for i, ci in enumerate(c):
        prev[i+1] = idx[ci][-1] if len(idx[ci]) > 0 else -1
        idx[ci].append(i+1)

    
    return prev
 
n = ni()
c = [ni() for _ in range(n)]
mod = 10**9+7

c = rem_alone(compress(c))

prev = find_prev_idx(c)

dp = [0]*(len(c)+1)
dp[0] = 1
for i in range(1, len(c)+1):
    dp[i] = dp[i-1] if prev[i] == -1 else dp[i-1] + dp[prev[i]]
    dp[i] %= mod

    
print(dp[len(c)])

Measured memory_bytes: 106292
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	
	String formulaStr = ""; //式を保存する文字列
	int index = 0; //式の文字列のインデックス
	
	public static void main(String[] args) {
		Main main = new Main();
		main.smartCalculator();
		return;
	}
	
	//四則演算を計算する
	private void smartCalculator() {
		
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); //標準入力
		
		try {
			
			String inputNumStr = bufferedReader.readLine();
			int inputNum = Integer.parseInt(inputNumStr); //与えられる式の数
			
			//式の計算
			for (int i = 0; i < inputNum; i++) {
				formulaStr = bufferedReader.readLine();
				index = 0;
				System.out.println(this.calculationFormula());
			}
			
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
		
	}
	
	//式の計算を行う
	private Long calculationFormula() {
		
		long answer = 0;
		
		answer = this.calculationAddSub();
		
		return answer;
	}
	
	//足し算、引き算の処理
	private Long calculationAddSub() {
		
		long answer = this.calculationMulDiv();
		
		while (true) {
			
			switch (formulaStr.charAt(index)) {
				case '+':
					index++;
					answer += this.calculationMulDiv();
					break;
				case '-':
					index++;
					answer -= this.calculationMulDiv();
					break;
				default:
					return answer;
			}
			
		}
	}
	
	//掛け算、割り算の処理
	private Long calculationMulDiv() {
		
		long answer = this.calculationTerm();
		
		while (true) {
			
			switch (formulaStr.charAt(index)) {
				case '*':
					index++;
					answer *= this.calculationTerm();
					break;
				case '/':
					index++;
					answer /= this.calculationTerm();
					break;
				default:
					return answer;
			}
			
		}
	}
	
	//括弧と数字の処理
	private Long calculationTerm() {
		
		long answer = 0;
		
		//括弧があった場合、優先して処理する
		if (formulaStr.charAt(index) == '(') {
			index++;
			answer = this.calculationAddSub();
			index++;
			return answer;
		}
		
		//数字の場合の処理
		if (Character.isDigit(formulaStr.charAt(index))) {
			return this.calculationValue();
		}
		
		return (long) 0;
	}
	
	//文字列から非演算子の数字のみを切り出す
	private Long calculationValue() {
		
		String tmpStr = formulaStr.substring(index); //処理が終わる前の式を切り出す
		String[] tmpStrs = tmpStr.split("[+-/\\*=)]");
		
		index += tmpStrs[0].length(); //インデックスの更新
		
		return Long.parseLong(tmpStrs[0]);
		
	}
}

Measured memory_bytes: 19580
s = input()
s = s[::-1]
while len(s)>0:
    if s[0:5] == 'dream'[::-1]:
        s = s[5:]
    elif s[0:7] == 'dreamer'[::-1]:
        s = s[7:]
    elif s[0:5] == 'erase'[::-1]:
        s = s[5:]
    elif s[0:6] == 'eraser'[::-1]:
        s = s[6:]
    else:
        print('NO')
        exit()

print('YES')
    

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(a) -- no. of elements strictly less than a
// s.find_by_order(i) -- itertor to ith element (0 indexed)
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef NOOBxCODER
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else 
    #define NOOBxCODER 0
    #endif
    //cin>>t;
    t=1;
    while(t--){
        cin>>n;
        ll a[n];
        fo(i,n)cin>>a[i];
        ll money=1000,stock=0;
        fo(i,n){
            if(i==0){
                if(a[i]>a[i+1]);
                else {
                    stock=1000/a[i];
                    money-=stock*a[i];
                }
            }
            else if(i==n-1){
                money+=stock*a[i];
            }
            else {
                if(a[i]>=a[i-1] && a[i]>a[i+1]){
                    money+=stock*a[i];
                    stock=0;
                }
                else if(a[i]<a[i-1]&& a[i]<=a[i+1]){
                    stock=money/a[i];
                    money-=stock*a[i];
                }
            }
            //cout<<money<<endl;
        }
        cout<<money<<endl;






        
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 3804
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int main(){
	int N;
	int d[101];
	cin >>N;
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}
	int ans = 0;
	for (int i = 0; i < N-1; i++) {
		for (int j = i + 1; j < N; j++) {
			ans += d[i] * d[j];
		}
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
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)*}
    };
}

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

use std::cmp::{min, max};
fn main() {
    input!{
        n: i64,
        k: i64,
        x: i64,
        y: i64,
    }
    println!("{}", min(n, k) * x + max(n-k, 0) * y);
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#pragma GCC optimize ("O3")

inline static int gl(void){
    int x = 0;
    for(;;){
        unsigned int c = getchar_unlocked() - 48;
        if(c < 10){
            x = x*10 + c;
        }else{
            break;
        }
    }
    return x;
}

inline static void pl(unsigned int s){
    char str[9];
    int pos=9;
    if(s==0){
        putchar_unlocked('0');
        return;
    }
    do{
        pos--;
        str[pos]=s%10+48;
        s/=10;
    }while(s!=0);
    for(; pos<9; pos++){
        putchar_unlocked(str[pos]);
    }
}

inline static int sp(char* str, unsigned short i){
    if(i>99){
        char c0 = i%10; i/=10;
        char c1 = i%10; i/=10;
        str[0] = i+48;
        str[1] = c1+48;
        str[2] = c0+48;
        return 3;
    }else if(i>9){
        char c0 = i%10; i/=10;
        str[0] = i+48;
        str[1] = c0+48;
        return 2;
    }else{
        str[0] = i+48;
        return 1;
    }
}

char a[501];
unsigned short out[1000000];
char buffer[8*1024*1024];

int main(void){
    const int h=gl(), w=gl();
    int pos=0;
    {
        char haveCoin = 0;
        short old_y, old_x;
        for(int i=1; i<=h; i++){
            for(int j=1; j<=w; j++){
                int t = getchar_unlocked() - 48;
                getchar_unlocked();
                a[j] = t;
            }
            if(i%2==1){
                for(int j=1; j<=w; j++){
                    if(haveCoin){
                        out[4*pos+0]=old_y;
                        out[4*pos+1]=old_x;
                        out[4*pos+2]=i;
                        out[4*pos+3]=j;
                        pos++;
                    }
                    haveCoin ^= a[j]&1;
                    old_y = i;
                    old_x = j;
                }
            }else{
                for(int j=w; j>0; j--){
                    if(haveCoin){
                        out[4*pos+0]=old_y;
                        out[4*pos+1]=old_x;
                        out[4*pos+2]=i;
                        out[4*pos+3]=j;
                        pos++;
                    }
                    haveCoin ^= a[j]&1;
                    old_y = i;
                    old_x = j;
                }
            }
        }
    }
    pl(pos); putchar_unlocked('\n');
    for(int i=0; i<pos; i++){
        char str[25];
        int p = 0;
        p += sp(str+p, out[4*i+0])+1; str[p-1] = ' '; 
        p += sp(str+p, out[4*i+1])+1; str[p-1] = ' '; 
        p += sp(str+p, out[4*i+2])+1; str[p-1] = ' '; 
        p += sp(str+p, out[4*i+3])+1; str[p-1] = '\n';
        fwrite(str, p, 1, stdout);
    }
    return 0;
}


Measured memory_bytes: 2944
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double pi = 3.141592653589;
        double r = sc.nextDouble();
        System.out.println(String.format("%.6f",r*r*pi)+" "+String.format("%.6f",2*r*pi));
    }
}



Measured memory_bytes: 28208
N = int(input())
S = []
for _ in range(N):
    S.append(int(input()))
S = sorted(S)

ans = sum(S)
if ans % 10 != 0:
    print(ans)
else:
    for s in S:
        if s % 10 != 0:
            print(ans - s)
            break
    else:
        print(0)

Measured memory_bytes: 3060
using System;

class project{
static void Main(){
  int n = Convert.ToInt32(Console.ReadLine());

  long[] h = new long[n];
  string[] inp = Console.ReadLine().Split(' ');
  for(int i = 0;i < n;i++){
  h[i] = Convert.ToInt64(inp[i]);
  }
  
  for(int i = n-1; i >1;i--){
    if(h[i] < h[i-1]-1)
     {
      Console.WriteLine("No");
      return;
    }else if (h[i]+1 == h[i-1])
      h[i-1] -=1;
  }

  Console.WriteLine("Yes");
}
}


Measured memory_bytes: 25440
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main()
{
    int D;
    cin >> D;
    cout << "Christmas";
    for (int i = 0; i < 25 - D; ++i)
    {
        cout << " Eve";
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void) {
    int a;
    int b;
    cin >> a >> b;
    
    string symbol;
    if (a < b) {
        symbol = " < ";    
    } else if (a > b) {
        symbol = " > ";
    } else {
        symbol = " == ";
    }
    
    cout << 'a' << symbol << 'b' << endl;
}

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

string s;
int n;

ll dfs(int i, ll sum, ll tmp)
{
    if (i == n - 1) return sum + tmp;
    ll r1 = dfs(i + 1, sum + tmp, s[i + 1] - '0');
    ll r2 = dfs(i + 1, sum, tmp * 10 + s[i + 1] - '0');
    return r1 + r2;
}

int main()
{
    cin >> s;
    n = s.length();
    cout << dfs(0, 0, s[0] - '0') << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <cassert>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

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

  bool odd = false, even = false;
  vector< pair<int64_t, int64_t> > a(n);
  rep(i, n) {
    int64_t x, y;
    cin >> x >> y;

    // For Debug
    // cout << "x: " << x << ", y: " << y << endl;
    if ((x+y) & 1) {
      odd = true;
      // cout << "odd" << endl;
    } else {
      even = true;
      // cout << "even" << endl;
    }
    a[i].first = x;
    a[i].second = y;
  }
  if (odd && even) {
    cout << -1 << endl;
    return 0;
  }

  int m = 31;
  // int m = 3;
  cout << (even ? m+1 : m) << endl;

  vector<int64_t> d(m);
  rep(i, m) {
    d[i] = 1ll << i;
  }
  reverse(all(d));
  for (auto& x : d) {
    cout << x << ' ';
  }
  if (even) {
    cout << 1 << endl;
  } else {
    cout << endl;
  }

  for (auto& p : a) {
    int64_t x, y;
    tie(x, y) = p;
    if (even) { --x; }
    string res;
    rep(i, m) {
      bool u = x+y>0, v = x-y>0;
      if (u  && v)  { res += "R", x -= d[i]; continue; }
      if (!u && v)  { res += "D", y += d[i]; continue; }
      if (u  && !v) { res += "U", y -= d[i]; continue; }
      if (!u && !v) { res += "L", x += d[i]; continue; }
    }
    assert(x == 0 && y == 0);
    if (even) { res += "R"; };
    cout << res << endl;
  }
}


Measured memory_bytes: 256
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
		
const double eps = 1e-9;																							   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////


///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    LL n, r;
    cin >> n >> r;
    
    if(n >= 10){
		cout << r << endl;
	}
	else{
		cout << r + (100 * (10 - n)) << endl;
	}
    
    
    
    
    
    
    
    
    
    
    
	
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
int main(){
  int N;
  cin >> N;
  int A[N], B[N];
  for(int i = 0; i < N; ++i){
    cin >> A[i];
    B[i] = A[i];
  }
  sort(B,B+N);
  
  map<int,int> id;
  for(int i = 0; i < N; ++i){
    id[B[i]] = i;
  }
  int ans = 0;
  for(int i = 0; i < N; ++i){
    ans += (id[A[i]]%2 - i%2 + 2)%2;
  }
  cout << ans/2 << endl;
  return 0;
}


Measured memory_bytes: 5760
import sys
input = sys.stdin.readline

#input
N = int(input())
A = str(input())
B = str(input())
C = str(input())

#output
difference = [0] * N
for i in range(N):
    if A[i] == B[i] == C[i]:
        difference[i] = 0
    elif A[i] == B[i] and A[i] != C[i]:
        difference[i] = 1
    elif A[i] == C[i] and A[i] != B[i]:
        difference[i] = 1
    elif B[i] == C[i] and B[i] != A[i]:
        difference[i] = 1
    else:
        difference[i] = 2
print(sum(difference))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll N; cin >> N;
    vector<ll> dp(N+1, N);
    dp[0] = 0;
    for (int i=0; i<N; ++i){
        dp[i+1] = min(dp[i+1], dp[i]+1);
        for (int j=6; i+j<=N; j*=6) dp[i+j] = min(dp[i+j], dp[i]+1);
        for (int j=9; i+j<=N; j*=9) dp[i+j] = min(dp[i+j], dp[i]+1);
    }
    cout << dp[N] << endl;
    return 0;
}

Measured memory_bytes: 3884
#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 

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N; cin >> N;
	int A[N];
	rep(i, N) cin >> A[i];
	int sum[N] = {};
	sum[0] = A[0];
	rep(i, N - 1) sum[i + 1] = A[i + 1] + sum[i];


	int L = 0, R = 2, mid = 1;
	int t[4] = {};
	t[0] = sum[L];
	t[1] = sum[mid] - sum[L];
	t[2] = sum[R] - sum[mid];
	t[3] = sum[N - 1] - sum[R];
	int ans = INF2;
	for (mid = 1; mid < N - 2; mid++) {
		t[0] = sum[L];
		t[1] = sum[mid] - sum[L];
		t[2] = sum[R] - sum[mid];
		t[3] = sum[N - 1] - sum[R];
		while (L < mid && abs(t[1] - t[0]) > abs((t[1] - A[L + 1]) - (t[0] + A[L + 1]) )){
			L++;
			t[0] = sum[L];
			t[1] = sum[mid] - sum[L];
		}
		while (R < N - 1 && abs(t[3] - t[2]) > abs((t[3] - A[R + 1]) - (t[2] + A[R + 1]))) {
			R++;
			t[2] = sum[R] - sum[mid];
			t[3] = sum[N - 1] - sum[R];
		}
		//rep(i, 4) cout << t[i] << " ";
		//cout << endl;
		ans = min(ans, max({ t[0], t[1], t[2], t[3] }) - min({ t[0], t[1], t[2], t[3] }));

	}
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define ll long long
#define faltu ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define binary(x) std::string binary = std::bitset<25>(x).to_string(); //to binary
#define inf 1000000007
#define mod 1000000007
#define pi pair<int,int>
#define lpi pair<int,int>
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define lvi vector<long long int>
#define pie 3.14159265358979323846
ll int MMM=inf;
int pw(ll int a, ll int b) {
    if (b == 0) return 1;
    ll int t = pw(a, b / 2);
    if (b % 2 == 0) return (t * t)%mod;
    else return ((t * t)%mod * a)%mod;
}
using namespace std;
vi pm;
void prm(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
              prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p]) pm.pb(p);
}
bool sortbysecdesc(const pair<ll int,ll int> &a,const pair<ll int,ll int> &b)
{
    return a.first>b.first;
}
bool cmp(int x,int y){return x>y;}
int gcd(int a,int b)
{
    if(a<b)
        swap(a,b);
    return (b==0)?a:gcd(b,a%b);
}
int main()
{
	faltu;
	int n,mx=0,mxx=0;
	cin>>n;
	int a[n+1];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		mx=max(mx,a[i]);
	}
	int ans=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]==mx&&ans==0)
		{
			ans=1;
		}
		else mxx=max(mxx,a[i]);
	}
	for(int i=0;i<n;i++)
	{
		if(a[i]==mx)cout<<mxx<<endl;
		else cout<<mx<<endl;
	}

}










Measured memory_bytes: 2432
#include<stdio.h>

#define S 0
#define H 1
#define C 2
#define D 3

int main(){
  int n,r;
  char ch;
  int card[4][13] = {};

  scanf("%d",&n);
  printf("%ls",&n);
  for( int i=0 ; i < n ; i++){
    scanf("%c",&ch);
    scanf("%c %d",&ch,&r);
    if( ch == 'S')card[S][r-1] = 1;
    if( ch == 'H')card[H][r-1] = 1;
    if( ch == 'C')card[C][r-1] = 1;
    if( ch == 'D')card[D][r-1] = 1;
  }
  for(int i=0 ; i < 4 ; i++){
    for(int j=0 ; j < 13 ; j++){
      if(!card[i][j]){
        if( i == S)printf("S %d\n",j+1);
        if( i == H)printf("H %d\n",j+1);
        if( i == C)printf("C %d\n",j+1);
        if( i == D)printf("D %d\n",j+1);
      }
    }
  }
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
const ll mod=1000000007;
ll gcd(ll a,ll b){if(a<b)swap(a,b);while((a%b)!=0){a=b;b=a%b;}return b;}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  int n; cin>>n;
  vector<int> t(n);
  int ans=0;
  rep(i,n){
    cin>>t[i];
    ans+=t[i];
  }
  int m; cin>>m;
  vector<int> X(m);
  rep(i,m){
    int p,x; cin>>p>>x;
    p--;
    ans+=x-t[p];
    X[i]=ans;
    ans+=t[p]-x;
  }
  rep(i,m)
  cout<<X[i]<<endl;

  return 0;
}


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

typedef vector<vvi> vvvi;
char c[]={'J','O','I'};
int main(){
	int m,n;
	cin>>m>>n;
	int k;
	cin>>k;
	vs field(m);
	REP(i,m){
		cin>>field[i];
	}

	vvvi joi(3,vvi(m+1,vi(n+1)));

	REP(i,3){
		FOR(y,1,m+1){
			FOR(x,1,n+1){
				joi[i][y][x]=joi[i][y][x-1]+(field[y-1][x-1]==c[i]);
			}
		}
	}
	REP(i,3){
		FOR(y,1,m+1){
			FOR(x,1,n+1){
				joi[i][y][x]+=joi[i][y-1][x];
			}
		}
	}

	REP(j,k){
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		REP(i,3){
			cout<<joi[i][c][d]-joi[i][c][b-1]-joi[i][a-1][d]+joi[i][a-1][b-1]<<(i==2?"":" ");
		}
		cout<<endl;
	}
		
}

Measured memory_bytes: 17900
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    string a;
    cin>>a;
    if (a=="A") {
        cout<<"T"<<endl;
    }else if(a=="T"){
        cout<<"A"<<endl;
    }else if (a=="C"){
        cout<<"G"<<endl;
    }else{
        cout<<"C"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	cin >> n;
	cout << arr[n-1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "

int main()
{
  int X;
  cin >> X;
  int piecset = X / 500;
  X %= 500;
  int piec = X / 5; 
  cout << piecset * 1000 + piec * 5 << endl;

}


Measured memory_bytes: 256