akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf = 10e17;
#define mod 1000000007
int findLowerBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{

    auto low = lower_bound(arr.begin(),
                           arr.end(), p);

    return low - arr.begin();
}
int findUpperBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{
    auto up = upper_bound(arr.begin(),
                          arr.end(), p);

    return up - arr.begin();
}
bool vis[200005];
vector<int> vec[2000005];
int child[2000005];
int parent[2000005];
int div1[100005];
void dfs(int node)
{
    vis[node] = 1;
    for (int i = 0; i < vec[node].size(); i++)
    {
        if (!vis[vec[node][i]])
        {
            parent[vec[node][i]] = node;
            dfs(vec[node][i]);
            //   child[node] += child[vec[node][i]];
        }
    }
}
void bfs(int node)
{
    queue<int> qu;
    qu.push(node);
    vis[1] = 1;
    while (!qu.empty())
    {
        int top = qu.front();
        //cout << qu.front() << "\n";
        qu.pop();
        vis[top] = 1;
        for (int i = 0; i < vec[top].size(); i++)
        {
            if (!vis[vec[top][i]])
            {
                parent[vec[top][i]] = top;
                qu.push(vec[top][i]);
                vis[vec[top][i]] = 1;
            }
        }
    }
}
void belman(int n, int m, vector<pair<int, pair<int, int>>> vec, int dis[])
{
    for (int i = 0; i <= n + m - 1; i++)
    {
        for (int j = 0; j < vec.size(); j++)
        {
            int u = vec[j].second.first;
            int v = vec[j].second.second;
            int w = vec[j].first;

            if (dis[u] + w < dis[v])
            {
                dis[v] = dis[u] + w;
            }
        }
    }
}
int fun(int a, int b)
{
    if (a > b)
        return 0;
    if (a == b)
        return 1;
    else
    {
        return fun(a + 1, b) + fun(a, b - a);
    }
}
int32_t main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);
    int n, m;
    cin >> n >> m;
    int sum = 1;
    for (int i = 0; i < m; i++)
    {
        int x, y;
        cin >> x >> y;
        vec[x].push_back(y);
        vec[y].push_back(x);
    }
    for (int i = 0; i <= n; i++)
        parent[i] = -1;

    bfs(1);
    // for (int i = 1; i <= n; i++)
    //   cout << parent[i] << "\n";
    for (int i = 1; i <= n; i++)
    {
        if (parent[i] == 1 && parent[n] == i)
        {
            cout << "POSSIBLE"
                 << "\n";
            return 0;
        }
    }
    cout << "IMPOSSIBLE"
         << "\n";

    return 0;
}


Measured memory_bytes: 60476
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

vector<ll> v[2000005];
ll n,q;
vector<ll> ad(200005,0);
vector<ll> ans(200005,0);
bool used[200005];
void search(ll pos, ll num){
    num += ad[pos];
    used[pos] = true;
    ans[pos] = num;
    rep(i,v[pos].size()){
        ll to = v[pos][i];
        if(!used[to]){
            search(to,num);
        }
    }
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> q;
  rep(i,n-1){
      ll a,b;cin >> a >> b;
      a--; b--;
      v[a].push_back(b);
      v[b].push_back(a);
  }
  rep(i,q){
      ll p,x;cin >> p >> x;
      p--;
      ad[p]+=x;
  }
  search(0,0);
  rep(i,n){
      cout << ans[i] << " " ;
  }
}

Measured memory_bytes: 68224
r,c = map(int, input().split())

matrix = []

for R in range(r):
    matrix.append(list(map(int, input().split())))
    matrix[R].append(sum(matrix[R]))

sumlist = []

for C in range(c+1):
    SUM = 0
    for R in range(r):
        SUM += matrix[R][C]
    sumlist.append(SUM)
matrix.append(sumlist)

for R in range(r+1):
    for C in range(c+1):
        if C != c:
            print(matrix[R][C],end=' ')
        else:
            print(matrix[R][C],end='')
    print(end='\n')


Measured memory_bytes: 6232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2007, mod = 1e9 + 7;
ll c[N][N];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    for(int i = 0; i <= n + 1; ++i){
        c[i][0] = 1;
        for(int j = 1; j <= i; ++j)
            c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
    }
    for(int i = 1; i <= k; ++i) 
        cout <<  c[k - 1][i - 1] * c[n - k + 1][i] % mod << endl;
    return 0;
}

Measured memory_bytes: 30208
use std::cmp::{max, min};
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, mut a: [usize; n]);
    let mut bases = vec![];
    let all = a.iter().fold(0, |b, x| b ^ *x);
    for ai in a.iter_mut() {
        *ai &= !all;
    }

    for &ai in a.iter() {
        let mut res = ai;
        for &b in bases.iter() {
            res = min(res, res ^ b);
        }
        if res > 0 {
            bases.push(res)
        }
    }
    bases.sort();
    for i in 0..bases.len() {
        for j in (i + 1)..bases.len() {
            bases[j] = min(bases[j], bases[j] ^ bases[i]);
        }
    }
    let x = bases.iter().fold(0usize, |b, x| b ^ *x);
    println!("{}", 2 * x + all);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
#define ll                long long int
#define ld                long double
#define pb                push_back
#define pf                push_front
#define ppb               pop_back
#define ppf               pop_front
#define sz                size()
#define pi                acos(-1.0)
#define mod               1000000007
#define maxe              max_element
#define mine              min_element
#define F                 first
#define S                 second
#define C                 continue
#define G                 goto done
#define mem(a,b)          memset(a,b,sizeof(a))
#define all(a)            (a).begin(),(a).end()
#define gcd(a,b)          __gcd(a,b)
#define lcm(a,b)          ((a)*((b)/gcd(a,b)))
#define point(a)          fixed<<setprecision(a)
#define get(a)            for(auto &x:a) cin>>x
#define print(a)          for(auto x:a) cout<<x<<" "; cout<<endl
#define see(x)            cout<<#x<<" = "<<x<<endl
#define uniq(a)           sort(all(a)); (a).erase(unique((a).begin(),(a).end()),(a).end())
#define fast              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define tc                int test; cin>>test; while(test--)
using namespace std;
int main()
{
    string s; cin>>s;
    if(s.back()=='s') s+="es";
    else s+="s";
    cout<<s;
}




















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

int main() {
  int64_t X, K, D;
  cin >> X >> K >> D;
  if(X < 0) {
    X = (-1) * X;
  }
  if(X >= 0) {
    int64_t i = X / D;
    if(K <= i) {
      cout << X - K * D << endl;
    }
    else {
      if(i % 2 == K % 2) {
        cout << X - i * D << endl;
      }
      else {
        cout << (i + 1) * D - X << endl;
      }
    }
  }
}

Measured memory_bytes: 3632
# AOJ 1004: Pair of Primes
# Python3 2018.7.4 bal4u

import sys
from sys import stdin
input = stdin.readline

MAX = 10000
SQRT = 100     # sqrt(MAX)

notprime = [False]*MAX
def sieve():
	notprime[1] = True
	notprime[2] = False 
	for i in range(3, SQRT, 2):
		if notprime[i] == False:
			for j in range(i*i, MAX, i): notprime[j] = True
sieve()


while True:
	try: k = int(input())
	except: break
	if (k&1) == 0: print(0 if notprime[k-1] else 2)
	elif k == 3: print(1)
	else:
		ans = 0
		s, p, q = 3, 3, k-2
		while q >= s:
			if not notprime[p] and not notprime[q]: ans += 1
			p, q = p+2, q-2
		print(ans)


Measured memory_bytes: 5712
import sys
from collections import deque
import copy
def main():
    N, M = map(int, input().split())
    dp = [[] for i in range(N)]
    color = [-1 for i in range(N)]
    distance = [10**5 for i in range(N)]
    color[0] = 0
    distance[0] = 0
    for i in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        dp[a].append(b)
        dp[b].append(a)
    queue = deque()
    queue.append((0, 0))
    while len(queue) != 0:
        now, d = queue.popleft()
        for i in range(len(dp[now])):
            if color[dp[now][i]] == -1 or distance[dp[now][i]] > d + 1:
                distance[dp[now][i]] = d + 1
                color[dp[now][i]] = now
                queue.append((dp[now][i], d + 1))
    for i in range(N):
        if color[i] == -1:
            print("No")
            sys.exit()
    print("Yes")
    for i in range(1, N):
        print(color[i] + 1)



if __name__ == '__main__':
    main()


Measured memory_bytes: 38988
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 29, 2019
 * 
 */

#include <bits/stdc++.h>

//#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

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

    vi h(n);

    iv(h);

    vi dp(n , INT_MAX);

    dp[0] = 0;

    rep(n){
        int temp = k;
        for(int j=i+1; j<n && temp; ++j){
            --temp;

            dp[j] = min(dp[j] , dp[i]+abs(h[i] - h[j]));
        }
    }

    cout<<dp[n-1]<<endl;



    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("bin","r",stdin);
    freopen("bout","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

using namespace std;
using ll = long long;

int main(){
  char a, b;
  scanf("%c %c", &a, &b);
  ll ll_a = 0;
  ll ll_b = 0;

  for(int i = 0; i < (int) (b - (char) '0'); i++){
    ll_a *= 10;
    ll_a += (ll) (a - (char) '0');
  }
  for(int i = 0; i < (int) (a - (char) '0'); i++){
    ll_b *= 10;
    ll_b += (ll) (b - (char) '0');
  }

  if(a <= b){
    printf("%lld\n", ll_a);
  } else {
    printf("%lld\n", ll_b);
  }
  return 0;
}


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

int main()
{
    string s, t;
    cin >> s >> t;
    int ls = s.length();
    int lt = t.length();
    int ans = ls;
    for (int i = 0; i <= ls - lt; i++)
    {
        int temp = 0;
        for (int j = i; j < i + lt; j++)
            if (s[j] != t[j - i])
                temp++;
        ans = min(ans, temp);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
 
using namespace std;
 
typedef unsigned long long ull;
typedef unsigned int uint;
typedef unsigned char uchar;
#define umap unordered_map
const static ull INVALID_DIGIT = ~(ull)0;

int main()
{
    int N, D;
    cin >> N >> D;
    N--;

    int persons = 1;

    int next = D * 2 + 1;
    while (next <= N) {
        persons++;
        next += D*2 + 1;
    }

    cout << persons << endl;

    return 0;
}

Measured memory_bytes: 256
use std::io::stdin;
use std::str::FromStr;
use std::collections::HashSet;

fn main() {
    let mut n = String::new();
    let mut d = String::new();
    
    stdin().read_line(&mut n).unwrap();
    
    let n: i32 = n.trim().parse().unwrap();
    let mut uniq: HashSet<String> = HashSet::new();
    for _i in 0..n {
        stdin().read_line(&mut d).unwrap();
        uniq.insert(d.clone());
        d.clear();
    }
    println!("{}", uniq.len());
}

#[allow(dead_code)]
fn read_elem<T: FromStr>() -> T {
    let mut l = String::new();
    stdin().read_line(&mut l).unwrap();
    l.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_n_elems<T: FromStr>() -> Vec<T> {
    let n = read_elem::<u32>();
    let mut vec: Vec<T> = vec![];
    for _i in 0..n {
        vec.push(read_elem::<T>());
    }
    vec
}

#[allow(dead_code)]
fn read_split_line<T: FromStr>() -> Vec<T> {
    let mut l = String::new();
    stdin().read_line(&mut l).unwrap();
    l.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 15276
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	ll n, k;
	ll s;
	cin >> n >> k >> s;

	if (s == 1000000000) {
		for (ll i = 0; i < k; i++) {
			cout << s << endl;
		}
		for (ll i = k; i < n; i++) {
			cout << s - 20 << endl;
		}

		return 0;

	}

	for (ll i = 0; i < k; i++) {
		cout << s << " ";
	}

	for (ll i = k; i < n; i++) {
		cout << s+20 << " ";
	}

	return 0;

}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; using ll = long long; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int K;
    string S;
    cin >> K >> S;
    cout << S.substr(0, min(K, (int)S.size())) << ((int)S.size() > K ? "...\n" : "\n");
}

Measured memory_bytes: 3648
// ARC090E.cpp
#include <bits/stdc++.h>

using namespace std;

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

const int MAX_N = 1e5 + 200, MAX_E = 2e5 + 200, mod = 1e9 + 7;

int n, m, start_pos, end_pos, xi[MAX_E], yi[MAX_E], wi[MAX_E], head[MAX_N], current;
int dp[2][MAX_N], deg[MAX_N];
ll dist[2][MAX_N];
bool vis[MAX_N];
vector<int> G[MAX_N];

struct edge
{
    int to, nxt, weight;
} edges[MAX_E << 1];

void addpath(int src, int dst, int weight)
{
    edges[current].to = dst, edges[current].nxt = head[src];
    edges[current].weight = weight, head[src] = current++;
}

void shortestPath(int src, int id)
{
    memset(dist[id], 0x3f, sizeof(dist[id]));
    memset(vis, false, sizeof(vis));
    priority_queue<pli> pq;
    pq.push(make_pair(0, src)), dist[id][src] = 0;
    while (!pq.empty())
    {
        int u = pq.top().second;
        pq.pop();
        if (vis[u])
            continue;
        vis[u] = true;
        for (int i = head[u]; i != -1; i = edges[i].nxt)
            if (dist[id][edges[i].to] > dist[id][u] + edges[i].weight)
            {
                dist[id][edges[i].to] = dist[id][u] + edges[i].weight;
                pq.push(make_pair(-dist[id][edges[i].to], edges[i].to));
            }
    }
}

void build(int src, int id)
{
    for (int i = 1; i <= n; i++)
        G[i].clear(), deg[i] = 0;
    for (int i = 1; i <= m; i++)
        for (int rd = 0; rd < 2; rd++)
        {
            swap(xi[i], yi[i]);
            if (dist[id][xi[i]] + wi[i] == dist[id][yi[i]])
                G[xi[i]].push_back(yi[i]), deg[yi[i]]++;
        }
    queue<int> q;
    q.push(src), dp[id][src] = 1;
    while (!q.empty())
    {
        int u = q.front();
        q.pop();
        for (int v : G[u])
        {
            dp[id][v] = (0LL + dp[id][v] + dp[id][u]) % mod;
            if (--deg[v] == 0)
                q.push(v);
        }
    }
}

int main()
{
    memset(head, -1, sizeof(head));
    scanf("%d%d%d%d", &n, &m, &start_pos, &end_pos);
    for (int i = 1; i <= m; i++)
        scanf("%d%d%d", &xi[i], &yi[i], &wi[i]), addpath(xi[i], yi[i], wi[i]), addpath(yi[i], xi[i], wi[i]);
    shortestPath(start_pos, 0), build(start_pos, 0);
    shortestPath(end_pos, 1), build(end_pos, 1);
    int ans = 1LL * dp[0][end_pos] * dp[0][end_pos] % mod;
    for (int i = 1; i <= n; i++)
        if (dist[0][i] == dist[1][i] && dist[0][i] + dist[1][i] == dist[0][end_pos])
            ans = (0LL + ans + mod - 1LL * dp[0][i] * dp[0][i] % mod * dp[1][i] % mod * dp[1][i] % mod) % mod;
    for (int u = 1; u <= n; u++)
        if ((dist[0][u] << 1) < dist[0][end_pos])
            for (int i = head[u]; i != -1; i = edges[i].nxt)
                if ((dist[1][edges[i].to] << 1) < dist[0][end_pos] && dist[0][u] + edges[i].weight + dist[1][edges[i].to] == dist[0][end_pos])
                    ans = (0LL + ans + mod - 1LL * dp[0][u] * dp[0][u] % mod * dp[1][edges[i].to] % mod * dp[1][edges[i].to] % mod) % mod;
    printf("%d\n", ans);
    return 0;
}

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

typedef long long ll;

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


Measured memory_bytes: 2944
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int Q = sc.nextInt();
        String S = sc.next();
        int[] l = new int[Q];
        int[] r = new int[Q];
        for(int i = 0; i < Q; i++){
            l[i] = sc.nextInt()-1;
            r[i] = sc.nextInt()-1;
        }
        int[] a = new int[N];
        for(int i = 0; i < N; i++){
            if(S.charAt(i) == 'A')
                a[i] = 1;
            if(S.charAt(i) == 'C')
                a[i] = -1;
        }
        int[] dp = new int[N];
        dp[0] = 0;
        for(int i = 0; i < N-1; i++){
            if(a[i] == 1 && a[i+1] == -1)
                dp[i+1] = dp[i] + 1;
            else
                dp[i+1] = dp[i];
        }
        for(int i = 0; i < Q; i++){
            System.out.println(dp[r[i]] - dp[l[i]]);
        }
    }
}


Measured memory_bytes: 84188
#include<iostream>
using namespace std;
int main(){
double a,b,t,cn,bs,x=0;
cin>>a>>b>>t;
cn=a;
for(;cn<t+0.5;){
    cn=cn+a;
    x++;
}
bs=x*b;
cout<<bs<<endl;
return(0);
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  if(x->left==NIL)
    return x;
  else
    return treeMinimum(x->left);

}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node np,z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  if(x==NULL){
    root=z;
    root->parent=NIL;
  }
  else{
  
  for(np=x;;){
    if(np->key>k){
      if(np->left!=NIL)
      np=np->left;
      else{
	np->left=z;
	break;
      }
    }
    else{
      if(np->right!=NIL){
	np=np->right;
	}
    else{
      np->right=z;
      break;
    }
	}
  }
  z->parent=np;
  }

}

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


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25140
//package com.company;

import java.io.*;
import java.util.*;


public class Main {
    public static class Task {

        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            long K = sc.nextInt();
            long A = sc.nextInt();
            long B = sc.nextInt();
            long biscuit = 1;
            if (K < A - biscuit) {
                pw.println(biscuit + K);
                return;
            }
            K -= (A - biscuit);
            biscuit = A;
            if (B - A >= 2) {
                long gain = B - A;
                long times = K / 2;
                biscuit += gain * times;
                K -= times * 2;
            }
            biscuit += K;
            pw.println(biscuit);

        }

    }

    private static long TIME_START, TIME_END;
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//        Scanner sc = new Scanner(new FileInputStream("23.in"));
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
//        PrintWriter pw = new PrintWriter(new FileOutputStream("froggy.out"));


//        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.in"));
        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
        System.out.println("Memory increased:" + (usedMemoryAfter-usedMemoryBefore) / 1000000 );
        System.out.println("Time used: " + (TIME_END - TIME_START) + ".");
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s){  br = new BufferedReader(new InputStreamReader(s));}

        public Scanner(FileReader s) throws FileNotFoundException {br = new BufferedReader(s);}

        public String next() throws IOException
        {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {return Integer.parseInt(next());}

        public long nextLong() throws IOException {return Long.parseLong(next());}

        public String nextLine() throws IOException {return br.readLine();}

        public double nextDouble() throws IOException { return Double.parseDouble(next()); }

        public boolean ready() throws IOException {return br.ready();}
    }
}

Measured memory_bytes: 22868
#[allow(unused_imports)]
use std::cmp::{max, min};

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    // from kenkoooooo
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.read()).collect()
    }

    fn usize_read(&mut self) -> usize {
        self.read()
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}

fn main() {
    let mut sc = Scanner::new();
    let mut n: i64 = sc.read();
    let mut m: i64 = sc.read();
    n -= 1;
    m -= 1;
    println!("{}", (n + m - 1) / m);
}


Measured memory_bytes: 4352
N, M = map(int, input().split())
lis = {}
if N == 1 and M == 0:
  print(0)
  exit()
if N == 2 and M == 0:
  print(10)
  exit()
if N == 3 and M == 0:
  print(100)
  exit()
if N == 1 and M == 1:
  s, c = map(int, input().split())
  print(c)
  exit()
for i in range(M):
  s, c = map(int, input().split())
  if s == 1 and c == 0:
    print(-1)
    exit()
  if s in lis:
    if lis[s] == c:
      continue
    else:
      print(-1)
      exit()
  else:
    lis[s] = c
if not 1 in lis:
  lis[1] = 1
for i in range(2, N+1):
  if not i in lis:
    lis[i] = 0
ans = ""
for i in range(1, N+1):
  ans += str(lis[i])
print(ans)

Measured memory_bytes: 9216
#include<stdio.h>

int GCD(int x, int y);

int main(void) {
    int x, y;
    scanf("%d %d", &x, &y);

    printf("%d\n", GCD(x, y));

    return 0;
}

int GCD(int x, int y) {
  int tmp, r;
  if(x < y) {
    tmp = x;
    x = y;
    y = tmp;
  }

  while(y > 0) {
    r = x % y;
    x = y;
    y = r;
  }

  return x;
}



Measured memory_bytes: 2112
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }

       




        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var abck = Reads();
            var a = abck[0];
            var b = abck[1];
            var c = abck[2];
            var k = abck[3];
            if (k % 2 == 0) Console.WriteLine(a - b);
            else Console.WriteLine(b - a);
            

            Console.Out.Flush();
        }
    }
}




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

int main(){
  int x, y;
  while(true){
    cin >> x >> y;
    if (x == 0 && y == 0) break;
    if (x < y){
      cout << x << ' ' << y << endl;
    }
    else{
      cout << y << ' ' << x << endl;
    }

  }
}


Measured memory_bytes: 3108
using System;
using System.Collections.Generic;
using System.Linq;

namespace _0046
{
    class Program
    {
        static void Main(string[] args)
        {
            string input;
            var mountList = new List<double>();
            while (true)
            {
                input = Console.ReadLine();
                if(string.IsNullOrEmpty(input))
                {
                    break;
                }
                mountList.Add(double.Parse(input));
            }
            Console.WriteLine(mountList.Max()-mountList.Min());
        }
    }
}

Measured memory_bytes: 5892
def loadIcicle():
	icicles = []
	line = input().strip().split(" ")
	N, L = int(line[0]), int(line[1])
	while True:
		icicles.append(int(input().strip()))
		if len(icicles) == N: break
	return icicles, N, L

def calcDiff(icicles, N):
	diff_2times = [0]*N

	for idx in range(N):
		dif_right = icicles[idx+1] - icicles[idx] if idx != N-1 else -icicles[idx]
		dif_left = icicles[idx] - icicles[idx-1] if idx != 0 else icicles[idx]

		dif_right = 1 if dif_right > 0 else -1
		dif_left = 1 if dif_left > 0 else -1

		if dif_right - dif_left < 0: diff_2times[idx] = -1
		elif dif_right - dif_left > 0: diff_2times[idx] = 1
		else: diff_2times[idx] = 0

	return diff_2times

icicles, N, L = loadIcicle()
diff_2times = calcDiff(icicles, N)

time = [-1]*N
peakX = [i for i in range(N) if diff_2times[i]==-1]
for i in peakX:
	time[i] = L - icicles[i]

	isLocalMinL, isLocalMinR = False, False
	posL, posR = i, i
	while not (isLocalMinL and isLocalMinR):
		posL -= 1
		if posL < 0:
			isLocalMinL = True
		if not isLocalMinL:
			if time[posL] == -1:
				time[posL] = (L-icicles[posL]) + time[posL+1]
			else:
				time[posL] = (L-icicles[posL]) + max(time[posL-1], time[posL+1])

			if diff_2times[posL] == 1:
				isLocalMinL = True

		posR += 1
		if posR >= N:
			isLocalMinR = True
		if not isLocalMinR:
			if time[posR] == -1:
				time[posR] = (L-icicles[posR]) + time[posR-1]
			else:
				time[posR] = (L-icicles[posR]) + max(time[posR-1], time[posR+1])

			if diff_2times[posR] == 1:
				isLocalMinR = True

print(max(time))

Measured memory_bytes: 17720
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    long long N, A, B;
    cin >> N >> A >> B;
    vector<long long> X(N);
    for(int i = 0; i < N ; i++) cin >> X[i];
    vector<long long> dp(N, 0);
    for(int i = 1; i < N; i++){
        dp[i] = min(dp[i - 1] + A*abs(X[i] - X[i - 1]), dp[i - 1] + B);
    }
    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

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

    ll cnt[S.size()] = {};
    // 移動先が現在の値と異なれば、そこで反復横跳びする
    ll tohyo[S.size()];

    ll mae = -1;
    REP(i,S.size())
    {
        ll j = i;
        ll moveCnt = 0;
        ll tobashi = 0;
        while(true)
        {
            if(S[j] == 'R')
            {
                if(S[j + 1] != S[j])
                {
                    if(moveCnt % 2 == 0)
                    {
                        for(ll k = 0; k < tobashi + 1; ++k)
                        {
                            if(k % 2 == 0)tohyo[i+k] = j;
                            else tohyo[i+k] = j+1;
                        }
                        //++cnt[j];
                    }
                    else
                    {
                        for(ll k = 0; k < tobashi + 1; ++k)
                        {
                            if(k % 2 == 0)tohyo[i+k] = j+1;
                            else tohyo[i+k] = j;
                        }
                        //++cnt[j+1];
                    }
                    i += tobashi;
                    break;
                }
                ++j;
                ++tobashi;
            }
            else
            {
                if(S[j - 1] != S[j])
                {
                    if(moveCnt % 2 == 0)
                    {
                        tohyo[i] = j;
                        mae = 1;
                    }
                    else
                    {
                        tohyo[i] = j-1;
                        mae = 2;
                    }
                    break;
                }
                if(mae == 1)
                {
                    tohyo[i] = tohyo[i-1] - 1;
                    mae = 2;
                    break;
                }
                else
                {
                    tohyo[i] = tohyo[i-1] + 1;
                    mae = 1;
                    break;
                }
                --j;
            }

            ++moveCnt;
        }
    }

    REP(i,S.size())
    {
        ++cnt[tohyo[i]];
    }

    REP(i,S.size())
    {
        cout << cnt[i] << " ";
    }

    cout << endl;


    return 0;
}

Measured memory_bytes: 2176
N,Q = map(int,input().split())
S = input()
lst = [0] * (N+1)
before = ''
count = 0
for i in range(len(S)-1):
    if S[i:i+2] == 'AC':
        count += 1
    lst[i+2] = count
for i in range(Q):
    l,r = map(int,input().split())
    print(lst[r]-lst[l])

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

const ll mod = 1000000007;
struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    // init struct with \"n\" of \"nCk\" (maximum number in other words)
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }
    // c(n,k) returns mint that contains nCk (mod p (= 1e9+7)) in x
    // i.e.) mint num = c(n,k), then num.x == nCk (mod p (= 1e9+7))
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }

    // nPk - permutation
    mint p(int n, int k) {
        return fact[n] * ifact[n - k];
    }
} nck(1000100);

mint solve(ll n, ll m, ll r) {
    auto calc = [&](ll offset) {
        mint acc = 0;
        for (ll k = 0; k <= r; ++k) {
            for (ll i = 0; i <= m; ++i) {
                ll deg = r - (i * (k + offset) + (k + 1) * (n - m));
                if(deg < 0) break;
                acc += nck(n + deg, deg) * nck(m, i) * (1 - i % 2 * 2);
            }
        }
        return acc;
    };

    mint all = 0;
    for (ll x = 0; x <= r; ++x) {
        all += nck(x + n - 1, x);
    }
    return all - nck(n, m) * (calc(1) - calc(0));
}

int main() {
	ll n, m, l, r;
    cin >> n >> m >> l >> r;
    m = n - m;
    mint ans = solve(n, m, r) - solve(n, m, l-1);
    cout << ans.x << endl;
}


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

typedef long long ll;
const ll mod = 1e9+7;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "]\n" : ", "); } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    string k;
    int d;
    cin >> k >> d;
    int n = k.size();
    vector<vector<vector<ll>>> dp(2,vector<vector<ll>>(n,vector<ll>(d,0)));
    int w = k[0]-'0';
    for (int i = 0;i < w;++i) dp[0][0][i%d] += 1;
    dp[1][0][w%d] = 1;
    for (int i = 1;i < n;++i) {
        int x = k[i]-'0';
        for (int j = 0;j < d;++j) dp[1][i][(j+x)%d] += dp[1][i-1][j];
        for (int j = 0;j < d;++j) for (int l = 0;l < x;++l) {
            dp[0][i][(j+l)%d] += dp[1][i-1][j];
            dp[0][i][(j+l)%d] %= mod;
        }
        for (int j = 0;j < d;++j) for (int l = 0;l < 10;++l) {
            dp[0][i][(j+l)%d] += dp[0][i-1][j];
            dp[0][i][(j+l)%d] %= mod;
        }
    }
    cout << (dp[0][n-1][0]+dp[1][n-1][0]-1+mod*2)%mod << endl;
    return 0;
}

Measured memory_bytes: 24832
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <climits>

using namespace std;

typedef long long ll;

int main() {
    int a, b;   cin >> a >> b;
    for (int i = 1; i <= 3; i++) {
        if (i != a && i != b)
            cout << i << endl;
    }
    return 0;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

struct edge { int a, b, c; };

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

    int n, m; cin >> n >> m;
    vector<vector<int>> g(n, vector<int>(n, inf));
    for (int i = 0; i < n; i++) g[i][i] = 0;
    vector<edge> edges(m);
    for (int i = 0; i < m; i++) {
        int a, b, c; cin >> a >> b >> c;
        a--, b--;
        g[a][b] = g[b][a] = c;
        edges[i] = {a, b, c};
    }
    
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }

    int ans = m;
    for (auto &e: edges) {
        bool flag = false;
        for (int s = 0; s < n - 1; s++) {
            for (int t = s + 1; t < n; t++) {
                if (g[s][e.a] + e.c + g[e.b][t] == g[s][t] || g[s][e.b] + e.c + g[e.a][t] == g[s][t]) {
                    flag = true;
                }
            }
        }
        if (flag) ans--;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
package main

import (
        "fmt"
        "strings"
)

func main() {
        var s string
        fmt.Scan(&s)

        answer := "None"
        for _, c := range "abcdefghijklmnopqrstuvwxyz" {
                sc := string(c)
                if strings.Index(s, sc) < 0 {
                        answer = sc
                        break
                }
        }

        fmt.Println(answer)
}


Measured memory_bytes: 1280
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  string S, T;
  cin >> S >> T;
  if (S == T) {
    cout << "Yes" << endl;
    return 0;
  }

  REP(i, 0, S.size()) {
    string s = S.substr(i, S.size() - i) + S.substr(0, i);
    if (s == T) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


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

bool solve() {
    int N; cin >> N;
    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];
    int cnt = 0;
    rep(i, N) {
        if(A[i] == B[i]) cnt++;
        else cnt = 0;
        if(cnt == 3) return true;
    }
    return false;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << (solve() ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int[] intArray = new int[a];
        int[] intArray2 = new int[a];
        for (int i = 0; i < a; i++) {
            int b = scanner.nextInt();
            intArray[i] = b;
        }
            for (int i = 0; i < a; i++) {
                intArray2[a - i - 1] = intArray[i];
            }
            for (int k = 0; k < a - 1; k++) {
                System.out.print(intArray2[k] + " ");
            }
            System.out.println(intArray2[a - 1]);
        }
}

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

from functools import lru_cache

MOD = 10 ** 9 + 7

def main():
    n, k = map(int, input().split())
    adj = [[] for i in range(n)]
    for i in range(n - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        adj[a].append(b)
        adj[b].append(a)
    res = k
    stack = [0]
    visited = [False for i in range(n)]
    while stack:
        i = stack.pop()
        visited[i] = True
        children = [x for x in adj[i] if not visited[x]]
        res *= perm((k - 1 if i == 0 else k - 2), len(children))
        res %= MOD
        for c in children:
            stack.append(c)
    print(res)

@lru_cache(maxsize=10 ** 6)
def perm(t, s):
    if s > t:
        return 0
    res = 1
    for i in range(s):
        res *= t
        res %= MOD
        t -= 1
    return res

if __name__ == "__main__":
    main()


Measured memory_bytes: 24960
n, l = gets.split.map(&:to_i)
tasts = []
min_t = 1000
ii = nil
n.times do |i|
  t = l + i
  tasts << t
  if t.abs < min_t
    min_t = t.abs
    ii = i
  end
end
tasts[ii] = 0
puts tasts.sum


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

#define faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2]<<nl;

    return 0;
}


Measured memory_bytes: 3592
import java.util.*;

class Main {
    static int W;
    static int H;
    static int s[][];
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        H = sc.nextInt();
        W = sc.nextInt();
        s = new int[H][W];
        for (int i = 0; i < H; i++) {
            String line = sc.next();
            for (int j = 0; j < W; j++) {
                char c = line.charAt(j);
                if (c == '.') {
                    s[i][j] = 0;
                } else {
                    s[i][j] = c - '0';
                }
            }
        }
        int count = 0;
        Set<Integer> set = rush0();
        while (set.size() > 0) {
            for(int x: set) {
                int i = x >> 16;
                int j = x & 0xffff;
                s[i][j] = 0;
            }
            count++;
            set = rush1(set);
        }
        System.out.printf("%d\n", count);
    }

    static Set<Integer> rush1(Set<Integer> set) {
        Set<Integer> set2 = new HashSet<Integer>();
        for(int x: set) {
            int p = x >> 16;
            int q = x & 0xffff;
            for (int i = p-1; i <= p+1; i++) {
                for (int j = q-1; j <= q+1; j++) {
                    if (i == p && j == q) continue;
                    if (s[i][j] > 0 && count(i, j) >= s[i][j]) {
                        set2.add(i << 16 | j);
                    }
                }
            }
        }
        return set2;
    }

    static int count(int p, int q) {
        int c = 0;
        for (int i = p-1; i <= p+1; i++) {
            for (int j = q-1; j <= q+1; j++) {
                if (s[i][j] == 0) c++;
            }
        }
        return c;
    }

    static Set<Integer> rush0() {
        Set<Integer> set = new HashSet<Integer>();
        for (int i = 1; i < H-1; i++) {
            for (int j = 1; j < W-1; j++) {
                if (s[i][j] > 0 && count(i, j) >= s[i][j]) {
                    set.add(i << 16 | j);
                }
            }
        }
        return set;
    }
}

Measured memory_bytes: 109968
import java.util.Scanner;

class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();

      if (b - a  == c - b ) {
        System.out.println("YES");
      }
      else {
        System.out.println("NO");
      }

  }
}


Measured memory_bytes: 23124
#include<cstdio>
using namespace std;

int main(){
  char N[5];
  scanf("%s", &N);
  bool ans = false;

  if (N[0] == '7') ans = true;
  if (N[1] == '7') ans = true;
  if (N[2] == '7') ans = true;

  if (ans) printf("Yes\n");
  else printf("No\n");

  return 0;
}

Measured memory_bytes: 3164
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<sstream>
#include<stack>
using namespace std;
int main(){
	stack<int> train;
	int a;
	while(cin>>a){
		int now;
		if(a==0){
		now=train.top();
		train.pop();
		cout<<now<<endl;
		}
		else {
			train.push(a);
		}
	}
	
    return 0;
}

Measured memory_bytes: 1200