akhauriyash/Code-Regression huggingface dataset:
/*
ID: barish21
LANG: C++14
TASK: test
*/

/****Author: Barish Namazov****/
#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <stack>
#include <cstring>
#include <cmath>

using namespace std;

/***TEMPLATE***/
#define intt long long

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sz(s) (intt)s.size()

#define ms0(arr) memset(arr,0,sizeof arr)
#define ms63(arr) memset(arr,63,sizeof arr)

#define forn(i,a,b) for(intt i=a;i<=b;i++)
#define rofn(i,a,b) for(intt i=a;i>=b;i--)
#define setf(it,myset) for(set<intt>::iterator it=myset.begin();it!=myset.end();it++)

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define VI vector<intt>
#define PII pair<intt,intt>
#define VPII vector< PII >

#define posl(ch) (int)(ch-'a'+1)
#define posL(ch) (int)(ch-'A'+1)

#define IO ios_base::sync_with_stdio(false);cin.tie();
/***************/

/***Additional Functions***/
intt powmod(intt a,intt b,intt mod){intt res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
intt gcd(intt a,intt b){return __gcd(a, b);}
intt lcm(intt a,intt b){return a*b/gcd(a,b);}
intt is_prime(intt n){if(n==1)return 0;if(n==2)return 1;if(n%2==0)return 0;for(intt i=3;i<=sqrt(n);i+=2)if(n%i==0)return 0;return 1;}
intt is_integer(double n){if(floor(n)==ceil(n))return 1;return 0;}

intt sto_int(string s){stringstream ss(s);intt n;ss>>n;return n;}
string to_string(intt n){stringstream ss;ss<<n;string s=ss.str();return s;}

/**************************/
const intt MAX = 100005;

intt xr[MAX];
intt trie[MAX][2], cnt[MAX], nxt = 1;

void add (string s) {
    intt node = 0;
    forn (i, 0, s.size() - 1)
        if (trie[node][s[i] - 48] == 0)
            node = trie[node][s[i] - 48] = nxt;
        else
            node = trie[node][s[i] - 48];
}
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    IO;
    /*
    intt n, x, k;
    cin >> n >> x;
    forn (i, 1, n) {
        cin >> k;
        xr[i] = k ^ xr[i - 1];
    }
    */
    intt n, m, a[51][2], b[51][2];
    cin >> n >> m;
    forn (i, 1, n) cin >> a[i][0] >> a[i][1];
    forn (i, 1, m) cin >> b[i][0] >> b[i][1];
    forn (i, 1, n) {
        intt mn = INT_MAX, in = 1;
        forn (j, 1, m)
            if (abs (a[i][0] - b[j][0]) + abs (a[i][1] - b[j][1]) < mn)
                mn = abs (a[i][0] - b[j][0]) + abs (a[i][1] - b[j][1]), in = j;
        cout << in << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int c = 0;
        for(int i=1; i<=n; i++) {
            int p = in.nextInt();
            if(i!=p) {
                c++;
            }
        }
        System.out.println((c==0||c==2) ? "YES" : "NO");
    }
}


Measured memory_bytes: 23124
s = list(input())
if s[0] == s[1] and s[2] == s[3] and s[1] != s[2]:
  print('Yes')
elif s[1] == s[2] and s[0] == s[3] and s[1] != s[0]:
  print('Yes')
elif s[1] == s[3] and s[0] == s[2]and s[1] != s[0]:
  print('Yes')

else:
  print('No')

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	int N;
	long[] A;
	long total = 0;
	long[] result;

	private Main() {
		Scanner in = new Scanner(System.in);
		N = Integer.parseInt(in.nextLine());
		String[] tokens = in.nextLine().split(" ");
		A = new long[N];
		for (int i = 0; i < N; ++i) {
			A[i] = Long.parseLong(tokens[i]);
		}
		result = new long[N];
		in.close();
	}

	private void calc() {
		calcTotal();
		long prev = 0;
		for (int i = 0; i + 1 < N; ++i) {
			if (prev < A[i] && A[i] < A[i + 1]) {
				// なにもしない
				result[i] = total;
			} else if (A[i + 1] < A[i] && A[i] < prev) {
				// なにもしない
				result[i] = total;
			} else {
				result[i] = total;
				result[i] -= (Math.abs(A[i] - prev) + Math.abs(A[i + 1] - A[i]));
				result[i] += Math.abs(A[i + 1] - prev);
			}
			prev = A[i];
		}
		if (A[N - 2] < A[N - 1] && A[N - 1] < 0) {
			result[N - 1] = total;
		} else if (0 < A[N - 1] && A[N - 1] < A[N - 2]) {
			result[N - 1] = total;
		} else {
			result[N - 1] = total;
			result[N - 1] -= (Math.abs(A[N - 1] - A[N - 2]) + Math.abs(A[N - 1]));
			result[N - 1] += Math.abs(A[N - 2]);
		}
	}

	private void show() {
		for (int i = 0; i < N; ++i) {
			System.out.println(result[i]);
		}
	}

	private void calcTotal() {
		long prevPoint = 0;
		for (int i = 0; i < N; ++i) {
			total += Math.abs(A[i] - prevPoint);
			prevPoint = A[i];
		}
		total += Math.abs(prevPoint);
	}

	public static void main(String[] args) {
		Main ins = new Main();
		ins.calc();
		ins.show();
	}

}


Measured memory_bytes: 52288
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,k;
  cin >> n >> k;
  if(n<=k){
    cout << "0" << endl;
    return 0;
  }
  vector<int>HP(n);
  for(int i=0;i<n;i++){
    cin >> HP.at(i);
  }
  sort(HP.begin(),HP.end());
  for(int i=0;i<k;i++){
    HP.pop_back();
  }
  long long sum=0;
  for(int i=0;i<HP.size();i++){
    sum+=HP.at(i);
  }
  cout << sum << endl;
}

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

int main(){
  int n,i,k,kotae=1000000000;
  cin>>n>>k;
  int a[n];
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a,a+n);
  for(i=0;i<n-k+1;i++){
    kotae=min(kotae,a[i+k-1]-a[i]);
  }
  cout<<kotae;
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <algorithm>

using namespace std;

int main()
{
    int A[3];
    for (int i = 0; i < 3; i++)
    {
        cin >> A[i];
    }

    sort(A, A + 3);
    

    if (A[0] == A[1] && A[0] == 5 && A[2] == 7)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}

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

int main(void){
  int n, m;
  cin>>n>>m;
  int min = 1000000, max = -1;
  int l, r;
  for(int i = 0 ; i < m ; i ++){
    cin>>l>>r;
    min = min < r ? min : r;
    max = max > l ? max : l;
  }
  // cout<<min<<' '<<max<<endl;
  if (min < max) {
    cout << 0 <<endl;
  } else {
    cout<<min - max + 1<<endl;
  }
}

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

int main() {
 
 int n;
 cin>>n;
 double arr[n];
 for(int i=0;i<n;i++)
 cin>>arr[i];
 sort(arr,arr+n);
 
 double sum=0;
 for(int i=0;i<n-1;i++) {
     sum=(arr[i]+arr[i+1])/2.0;
     arr[i+1]=sum;
 }
 
 cout << sum << endl;
 
  return 0;
}

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

using namespace std;

#define pb push_back
#define mem(a) memset(a,0,sizeof(a))

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

const int mn=3e5+5;

int n;
char s[mn];
int w[mn],e[mn];

int main() {
#ifdef LOCAL
	freopen("../1.txt", "r", stdin);
#endif
	scanf("%d%s",&n,s+1);
	for(int i=1;i<=n;i++){
		if (s[i]=='W') w[i]++;
		w[i]+=w[i-1];
	}
	for(int i=n;i;i--){
		if (s[i]=='E') e[i]++;
		e[i]+=e[i+1];
	}
	int ans=1e9;
	for(int i=1;i<=n;i++) ans=min(ans,w[i-1]+e[i+1]);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 2944
// I can't tell you what it really is,
// I can only tell you what it feels like.
#include "bits/stdc++.h"
using namespace std;
#define int long long
const int N = 10000 + 2;
const int mod = 1e9 + 7;

char s[N];
int dp[N][100][2], d, n;


int go(int id, int md, bool f = false) {
  if (id == n) {    
    return !md;
  }
  if (~dp[id][md][f]) return dp[id][md][f];
  long long ans = 0, dig = s[id] - '0';
  for (int i = 0; i < 10; ++i) {
    if (f == false && i > dig) break;
    ans += go(id+1, (md+i)%d, f|(i<dig));
  }
  while (ans >= mod) ans -= mod;
  return dp[id][md][f] = ans;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> s >> d;
  memset(dp, -1, sizeof dp);  
  n = strlen(s);  
  int ans =  go(0,0,0) - 1;
  if (ans < 0) ans += mod;
  cout << ans;  
  return 0;
}
// 1). Try forming/rearranging the equations if any
// 2). If problem asks to count, try counting in reverse(it can be easier sometimes)


Measured memory_bytes: 16640
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>
ll dp[100005];

int main() {
	ll n, m;
	cin >> n >> m;
	vector<ll>c(n+1,2);
	ll buf(0);
	
	rep(i, m) {
		ll k;
		cin >> k;
		if (buf + 1 == k && i>=1) {
			cout << "0";
			return 0;
		}
		buf = k;
		c[k]=0;

	}
	ll mod = 1000000007;
	dp[0] = 1;
	rep(i, n+1) {
		if (i == 0)continue;
		if (c[i] == 0)continue;
		if (i == 1) {
			dp[i] = 1;
			continue;
		}
		dp[i] = dp[i - 2] + dp[i - 1];
		//cout << dp[i - 2]<<" " << dp[i - 1]<<" ";
		dp[i] %= mod;
		//cout << dp[i]<<i<<endl;
	}
	cout << dp[n];
	return 0;
}

Measured memory_bytes: 4768
//
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(size_t i = 0; i < (n); ++i)

int main()
{
    ll X, K, D;
    cin >> X >> K >> D;
    ll q = X / D;
    ll r = X % D;
    if (X > 0)
    {
        if (K >= q)
        {
            if ((K - q) % 2 == 0)
            {
                ll ans = r;
                cout << ans << endl;
                return 0;
            }
            else
            {
                if (K > q)
                {
                    ll ans = min(r + D, abs(r - D));
                    cout << ans << endl;
                    return 0;
                }
                else
                {
                    ll ans = abs(X - K * D);
                    cout << ans << endl;
                    return 0;
                }
                
            }
            
        }
        else
        {
            ll ans = abs(X - K * D);
            cout << ans << endl;
            return 0;
        }
    }
    else
    {
        if (K >= abs(q))
        {
            if ((K - abs(q)) % 2 == 0)
            {
                ll ans = abs(r);
                cout << ans << endl;
                return 0;
            }
            else
            {
                if (K > abs(q))
                {
                    ll ans = min(r + D, abs(r - D));
                    cout << ans << endl;
                    return 0;
                }
                else
                {
                    ll ans = abs(X + K * D);
                    cout << ans << endl;
                    return 0;
                }
            }
        }
        else
        {
            ll ans = abs(X + K * D);
            cout << ans << endl;
            return 0;
        }
    }
    return 0;
}


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

int main(){
    int k,a,b;
    cin>>k>>a>>b;
    for(int i=a; i<=b; i++){
        if(i%k==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
}






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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(1e5) + 17;

int n;
vector<int> g[MAXN];
ll dp[MAXN][2];

bool read() {
    if (!(cin >> n))
        return false;

    forn (i, n - 1) {
        int u, v;
        cin >> u >> v;
        g[u - 1].pb(v - 1);
        g[v - 1].pb(u - 1);
    }

    return true;
}

void dfs(int v, int p) {
    dp[v][0] = dp[v][1] = 1;

    for (auto to : g[v])
        if (to != p) {
            dfs(to, v);
            dp[v][0] *= dp[to][0] + dp[to][1];
            dp[v][0] %= INF;
            dp[v][1] *= dp[to][0];
            dp[v][1] %= INF;
        }
}

void solve() {
    dfs(0, -1);
    cout << (dp[0][0] + dp[0][1]) % INF << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 14208
A,B=map(int,input().split())
N=len(str(bin(B)))-2

p=[1]*(N+1)
for i in range(N):
    p[i+1]=p[i]*2
    
def calc(b):
    ans=0
    for i in range(N):
        cnt=(b//p[i+1])*p[i] + max(0,b%p[i+1]-(p[i]-1))
        ans+=cnt%2*p[i]
    return ans

print(calc(B) ^ calc(max(0,A-1)))




Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int n; cin >> n;
  COUT(n%2 ? n*2 : n);
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
typedef long long LL;
using ld = long double;
using namespace std;
#define MAXN 500005
const double eps = (1e-11);
const int logn = 21;
const double pi = acos(-1.0);
int pp = 1000000007;
#define P pair<int,int>
#define se second
#define fi first
#define MP(i,j) make_pair(i,j)
//#define int LL
const int INF = 1e9;

//假题，贪心模拟^
//正解霍尔定理？下次下次
struct peo {
	int l; int r;
};

peo p[MAXN];

//这里肯定是要从小到大，这样就可以尽量填小的了
bool cmp1(peo a, peo b) {
	if (a.l == b.l) return a.r < b.r;
	return a.l < b.l;
}

bool operator <(peo a, peo b) {
	return a.r > b.r;
}

priority_queue<peo> q;
priority_queue<int> q2;

signed main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		scanf("%d%d", &p[i].l, &p[i].r);
	}
	sort(p + 1, p + n + 1, cmp1);
	int left = 0;
	for (int i = 1; i <= n; i++) {
		q.push(p[i]);
		if (q.size() > p[i].l) {
			q2.push(q.top().r);
			q.pop();
		}
	}
	int ans = q.size();
	int r = m + 1;
	int ans2 = 0;
	while (!q2.empty()) {
		int tmp = q2.top(); q2.pop();
		r = min(tmp, r);
		r = max(tmp, ans + 1);
		if (ans2 < m - r + 1) {
			ans2++;
		}
	}
	ans += ans2; ans = n - ans;
	printf("%d", ans);
	return 0;
}

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

int main()
{
    int n, c, k;
    cin >> n >> c >> k;
    vector<int> t(n);
    rep(i, n) cin >> t[i];
    sort(t.begin(), t.end());
    int pnum = 0;
    int st = t[0];
    int ti = t[0];
    int ans = 1;
    rep(i, n) {
        ti = t[i];
        pnum++;
        if(pnum > c || st + k < ti) {
            ans++;
            pnum = 1;
            st = t[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3744
N = int(input())
nodes = [[-1,-1,-1] for i in range(N)]

for k in range(N):
    i,l,r = map(int,input().split())
    nodes[i][1] = l
    nodes[i][2] = r
    if l != -1:
        nodes[l][0] = i
    if r != -1:
        nodes[r][0] = i

#print(nodes)

def preParse(u):
    if u == -1:
        return
    print(' {}'.format(u), end='')
    preParse(nodes[u][1])
    preParse(nodes[u][2])

def inParse(u):
    if u == -1:
        return
    inParse(nodes[u][1])
    print(' {}'.format(u), end='')
    inParse(nodes[u][2])

def postParse(u):
    if u == -1:
        return
    postParse(nodes[u][1])
    postParse(nodes[u][2])
    print(' {}'.format(u), end='')

root = 0
while nodes[root][0] != -1:
    root = nodes[root][0]

print('Preorder')
preParse(root)
print()

print('Inorder')
inParse(root)
print()

print('Postorder')
postParse(root)
print()



Measured memory_bytes: 5620
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
edge=[[] for i in range(3*n)]
for i in range(m):
  u,v=map(int,input().split())
  for j in range(3):
    edge[u-1+j*n].append([1,(v-1+(j+1)*n)%(3*n)])
import heapq
def dijkstra_heap(s):
  d=[float("inf")]*(3*n)
  used=[True]*(3*n)
  d[s]=0
  used[s]=False
  edgelist=[]
  for e in edge[s]:
    heapq.heappush(edgelist,e)
  while edgelist:
    minedge = heapq.heappop(edgelist)
    if not used[minedge[1]]:
      continue
    v = minedge[1]
    d[v] = minedge[0]
    used[v] = False
    for e in edge[v]:
      if used[e[1]]:
        heapq.heappush(edgelist,[e[0]+d[v],e[1]])
  return d
s,t=map(int,input().split())
ans=dijkstra_heap(s-1)[t-1]
print(ans//3 if ans%3==0 else -1)

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

int main(){
	int a,b;
	cin >> a >> b;
	int ans=0;
	for(int i=a; i<=b; i++){
		string s = to_string(i);
		if(s[0]==s[4] && s[1]==s[3]) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
int main(void){
    unsigned long long a, n, ans;
    bool flag = true;
    cin >> n;
    cin >> ans;
    
    for(int i = 1;i < n;i++){
        cin >> a;
        
        if(a == 0){
            cout << 0;
            return 0;
        }
        else{
            if(a > 1000000000000000000 / ans){
                flag = false;
            }
            else{
                 ans *= a;
            }
        }
        
    }
    
    if(flag == true){
        cout << ans;    
    }
    else{
        cout << -1;
    }
    
    return 0;
    
}


Measured memory_bytes: 3608
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int[] prize = new int[4] { 300000, 200000, 100000, 0 };
		int X = Min(3, GetInt() - 1);
		int Y = Min(3, GetInt() - 1);
		int ans = prize[X] + prize[Y];
		if(X == 0 && Y == 0)
			ans += 400000;

		WriteLine(ans);
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

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

int main()
{
    int S, h, m, s;

    cin >> S;
    s = S % 60;
    h = S / 3600;
    m = (S - s - h * 3600) / 60;

    cout << h << ":" << m << ":" << s <<"\n";
}


Measured memory_bytes: 3096
#include<iostream>
#include <vector>
#include<string.h>
using namespace std;

int main(){
   int N;
   string S;
   cin>>N;
   cin>>S;
   string result = ""; 
   for(int i=0;i<int(S.length());i++){
       result += char(int(S[i]+N-65)%26 +65); 
   }
   cout<<result<<endl;
   return 0;
}

Measured memory_bytes: 256
MOD = 10**9 + 7
L = input().rstrip()
if L == "1":
    print(3)
    exit()
n = len(L)

ans = 0
l_num = L.count("1")
dp_t = [[0] * n for _ in range(2)]
dp_l = [[0] * n for _ in range(2)]
dp_t[1][0] = 2
dp_l[0][1] = 1
dp_l[1][1] = 2
for i in range(1, n):
    if L[i] == "0":
        dp_t[0][i] += dp_t[0][i-1] + dp_t[1][i-1] 
    elif L[i] == "1":
        dp_t[1][i] += (dp_t[0][i-1] + dp_t[1][i-1]) * 2
        dp_l[0][i] += dp_t[0][i-1] + dp_t[1][i-1]
    dp_l[0][i] += dp_l[0][i-1] + dp_l[1][i-1]
    dp_l[1][i] += (dp_l[0][i-1] + dp_l[1][i-1]) * 2

    dp_l[1][i] %= MOD
    dp_l[0][i] %= MOD
    dp_t[1][i] %= MOD
    dp_t[0][i] %= MOD

print((dp_t[1][n-1] + dp_t[0][n-1] + dp_l[1][n-1] + dp_l[0][n-1]) % MOD)

Measured memory_bytes: 15936
from bisect import bisect_left,bisect
n = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0
#c - b < a < c + b
for i in range(n-1):
    for j in range(i+1,n):
        sahen = bisect(l,l[j]-l[i])
        uhen = bisect_left(l,l[j]+l[i])
        ans += uhen - sahen
        if sahen <= i <= uhen -1:
            ans -= 1
        if sahen <= j <= uhen -1:
            ans -= 1
print(ans//3)

Measured memory_bytes: 47880
k,s = list(map(int,input().split()))
ans = 0
for i in range(k+1):
    for j in range(0,s-i+1):
        if j > k:
            break
        else:
            p = s-i-j
            if p<0:
                pass
            elif p > k:
                pass 
            else:
                ans += 1
                # print("X,Y,z = ",i,j,p," :|")

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
using namespace std;
const int tINF = (int)INT_MAX;
const long long lINF = (long long)LLONG_MAX;

int main() {
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef DEBUG
			assert(freopen("inp", "r", stdin));
			assert(freopen("out", "w",stdout));
	#else
			#define cerr if(false)cerr
	#endif
    vector <int> ar(3);
    for(auto &i : ar)
        cin >> i;
    sort(all(ar));
    if(ar[0] == ar[1] && ar[0] != ar[2])
        cout << "Yes\n";
    else if(ar[1] != ar[0] && ar[1] == ar[2])
        cout << "Yes\n";
    else
        cout << "No\n";
   cerr << "Time execute: " << (double)clock() / (double)CLOCKS_PER_SEC 
    << " sec" << endl;
}

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

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    ans += b-a+1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>

#include <iostream>
using namespace std;

int main(){
    string s;
    string t;
    cin>>s;
    cin>>t;
    
    for (int i=0; i<s.length(); i++) {
        long int num=s.length()-i-1;
        for (int k=0; k<num; k++) {
            if (s[k]>s[k+1]) {
                char mae=s[k+1];
                char ato=s[k];
                s[k]=mae;
                s[k+1]=ato;
            }
        }
    }
    
    for (int i=0; i<t.length(); i++) {
        long int num=t.length()-i-1;
        for (int k=0; k<num; k++) {
            if (t[k]>t[k+1]) {
                char mae=t[k+1];
                char ato=t[k];
                t[k]=mae;
                t[k+1]=ato;
            }
        }
    }
    
    string t2;
    t2=t;
    
    for (int i=0; i<t.length(); i++) {
        t[i]=t2[t.length()-1-i];
    }
    
    if (s<t) {
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    
    
}


Measured memory_bytes: 256
n=int(input())
blocks=[int(i) for i in input().split()]
# print(blocks)
pre = blocks[-1]
no_flag = 0
cannot_down = 0
for this_block in reversed(blocks):
    if (this_block - pre) > 1:
        no_flag = 1
        break
    elif (this_block - pre) == 1:
        pre = (this_block - 1)
    else:
        pre = this_block
if no_flag:
    print("No")
else:
    print("Yes")

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

typedef long long int ll;
ll powk(ll a, ll n = 2){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}


int main()
{
    ll sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    ll rl = abs(sx - tx), ud = abs(sy - ty);
    for(ll i = 0;i < ud;i++){
        cout << 'U';
    }
    for(ll i = 0;i < rl;i++){
        cout << 'R';
    }
    for(ll i = 0;i < ud;i++){
        cout << 'D';
    }
    for(ll i = 0;i < rl;i++){
        cout << 'L';
    }
    cout << 'L';
    for(ll i = 0;i < ud + 1;i++){
        cout << 'U';
    }
    for(ll i = 0;i < rl + 1;i++){
        cout << 'R';
    }
    cout << 'D';
    cout << 'R';
    for(ll i = 0;i < ud + 1;i++){
        cout << 'D';
    }
    for(ll i = 0;i < rl + 1;i++){
        cout << 'L';
    }
    cout << 'U';

    return 0;
}

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

using namespace std;

int main() {
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;

    int aa = (a % 10 == 0 ? a : (a / 10 + 1) * 10);
    int bb = (b % 10 == 0 ? b : (b / 10 + 1) * 10);
    int cc = (c % 10 == 0 ? c : (c / 10 + 1) * 10);
    int dd = (d % 10 == 0 ? d : (d / 10 + 1) * 10);
    int ee = (e % 10 == 0 ? e : (e / 10 + 1) * 10);

    int diff = std::max({aa - a, bb - b, cc - c, dd - d, ee - e});

    cout << aa + bb + cc + dd + ee - diff << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<set>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF 1000000100
#define rep(i,n) for (int i=0;i<n;i++)

string s,t;
map<int,vector<int>> mp;
set<int> sets;

int check(int l,int r, int pre){
    int next=-1;
    int now=t[r-1];
    if(sets.find(now)==sets.end()){
        return -10;
    }
    auto itr = find(mp[now].begin(), mp[now].end(), pre); 
    if(itr!=mp[now].end()){
        if(itr==mp[now].end()-1){
            return -1;
        }
        itr++;
        return *itr;
    }
    rep(i,mp[now].size()){
        if(mp[now][i]>pre){
            next=mp[now][i];
            return next;
        }
    }
    return next;
}

int main(){
    cin >> s >> t;
    rep(i,s.size()){
        mp[s[i]].push_back(i);
        sets.insert(s[i]);
    }
    int sum=0;
    int l=0, r=1;
    int next=-1; 
    int pre=-1;
    while(l<t.size() && r<t.size()+1){
        next = check(l,r,pre);
        if(next==-10){
            cout << -1 << endl;
            return 0;
        }
        if(next!=-1){
            r++;
            pre=next;
        }
        else{
            sum+=1;
            l=r-1;
            pre=-1;
        }

    }
    ll ans = sum*s.size()+pre+1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3852
#include<iostream>
using namespace std;
/*int parts[100000];
int res[100000][400];
bool state[100000];*/
int main(){
  int a,b,c,many,n;
  while(cin >> a >> b >> c, a){
    many = a+b+c;
    int parts[many];
    for(int i=0;i<many;i++){
      parts[i]=2;
    }
    cin >> n;
    //int A[n],B[n],C[n];
    int res[1000][4];
    bool state[1000];

    
    for(int i=0;i<n;i++){ //表入力
      cin >> res[i][0] >> res[i][1] >> res[i][2] >> state[i];
      
      res[i][0]--;
      res[i][1]--;
      res[i][2]--;
      if(state[i]){
	parts[res[i][0]]=1;
	parts[res[i][1]]=1;
	parts[res[i][2]]=1;
      }
      
    }
    
    for(int i=0;i<n;i++){ //故障品探し(一回全部のデータを取り込んでからやるらしい)
      if(!state[i]){
	if(parts[res[i][0]]==1 && parts[res[i][1]]==1) parts[res[i][2]]=0;
	if(parts[res[i][1]]==1 && parts[res[i][2]]==1) parts[res[i][0]]=0;
	if(parts[res[i][0]]==1 && parts[res[i][2]]==1) parts[res[i][1]]=0;
      }
    }
    
    for(int i=0;i<many;i++){
      cout << parts[i] << endl;
    }
  }
}

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

int main(){
    long int n;
    cin >> n;
    vector <long int> a(n); rep(i, n) cin >> a[i];
    vector <long int> lm(n, 0);
    vector <long int> rm(n, 0); 

    for(int i = 1; i < n; i++) lm[i] = max(lm[i - 1], a[i - 1]);
    for(int i = n - 2; i >= 0; i--) rm[i] = max(rm[i + 1], a[i + 1]);

    for(int i = 0; i < n; i++) cout << max(rm[i], lm[i]) << endl;

    return 0;
}


Measured memory_bytes: 6272
#include<stdio.h>
#include<string.h>
int main()
{
    int n,a[100],i,s=0,t=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        s=s+a[i];
    }
    if(s%10!=0) printf("%d",s);
    else
    {
        for(i=0;i<n;i++)
        if((s-a[i])%10!=0&&(s-a[i])>t) t=s-a[i];
        printf("%d\n",t);
    }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,k,sum=0;
   vector<int>v;
   cin>>n>>k;
   for(int i=0;i<n;i++)
   {
       int a;
       cin>>a;
       v.push_back(a);
   }
   sort(v.begin(),v.end());
   for(int j=0;j<k;j++)
   {
       sum+=v[j];
   }
   cout<<sum<<endl;
   return 0;
}


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

int max(int a,int b){
  if(a>b) return a;
  else return b;
}
double min(double a,double b){
  if(a<b) return a;
  else return b;
}
int absolute(int a,int b){
  if(a-b<0) return -(a-b);
  else return a-b;
}

int main(void){
  int n; cin >> n;
  
  int totalcount = 0 ;
  for(int N = 1; N<=n ; N++){
    int count = 0;
  	for(int i = 1; i<=N ; i+=2){
    	if(N%i==0) count++;
    }
    //cout << "N:" << N << " count:" << count << endl;
    if(count == 8) totalcount++;
  }
  cout << totalcount << endl;
}

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

#define MAX_K (100000)
#define MAX_L (100000)

using namespace std;

void add_edge(vector<vector<int>> &adj_lists, int i, int j) {
  adj_lists[i].push_back(j);
  adj_lists[j].push_back(i);
}

void dfs(vector<vector<int>> &adj_lists, vector<int> &gs, int i, int g) {
  gs[i] = g;
  for (int j : adj_lists[i]) {
    if (gs[j] < 0) {
      dfs(adj_lists, gs, j, g);
    }
  }
}

int main() {
  // read inputs
  int N, K, L, ps[MAX_K], qs[MAX_K], rs[MAX_L], ss[MAX_L];
  scanf("%d %d %d", &N, &K, &L);
  for (int i = 0; i < K; i++) {
    scanf("%d %d", &ps[i], &qs[i]);
    ps[i]--;  // NOTE : modified input
    qs[i]--;  // NOTE : modified input
  }
  for (int i = 0; i < L; i++) {
    scanf("%d %d", &rs[i], &ss[i]);
    rs[i]--;  // NOTE : modified input
    ss[i]--;  // NOTE : modified input
  }

  // create graphs
  vector<vector<int>> road_adj_lists(N, vector<int>()),
      railway_adj_lists(N, vector<int>());
  for (int i = 0; i < K; i++) {
    add_edge(road_adj_lists, ps[i], qs[i]);
  }
  for (int i = 0; i < L; i++) {
    add_edge(railway_adj_lists, rs[i], ss[i]);
  }

  // decompose
  vector<int> road_gs(N, -1), railway_gs(N, -1);
  int g = 0;
  for (int i = 0; i < N; i++) {
    if (road_gs[i] < 0) {
      dfs(road_adj_lists, road_gs, i, g++);
    }
  }
  g = 0;
  for (int i = 0; i < N; i++) {
    if (railway_gs[i] < 0) {
      dfs(railway_adj_lists, railway_gs, i, g++);
    }
  }

  // create vector of (road_g, railway_g)
  vector<pair<int, int>> pgs;
  for (int i = 0; i < N; i++) {
    pgs.push_back(pair<int, int>(road_gs[i], railway_gs[i]));
  }
  sort(pgs.begin(), pgs.end());

  // solve
  for (int i = 0; i < N; i++) {
    const pair<int, int> pg = pair<int, int>(road_gs[i], railway_gs[i]);
    const int cnt = upper_bound(pgs.begin(), pgs.end(), pg) -
                    lower_bound(pgs.begin(), pgs.end(), pg);
    printf("%d ", cnt);
  }
  printf("\n");
}

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

using namespace std;
int n;
pair<long long int ,long long int > a[1000];
long long int dp[100002][101];
long long int maxsum(int w,int x)
{
	if(dp[w][x]!=-1)
		return dp[w][x];
	else if(w==0)
		dp[w][x]=0;
	else if(x>n)
	{
		dp[w][x]=0;
	}
	else if(w>=a[x].first)
		dp[w][x]= max(maxsum(w-a[x].first,x+1)+a[x].second,maxsum(w,x+1));
	else 
		dp[w][x]=maxsum(w,x+1);
	return dp[w][x];
}
int main()
{
	int w;
	cin>>n>>w;
	for (int i = 1; i <= n; ++i)
	{
		cin>>a[i].first>>a[i].second;
	}
	for (int i = 0; i < 100002; ++i)
	{
		for (int j = 0; j < 101; ++j)
		{
			dp[i][j]=-1;
		}
	}
	cout<<maxsum(w,1)<<'\n';
}

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

int main(){
  int h,n,a=0;
  cin >> h >> n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  for(int i=0;i<n;i++){
    a=a+v[i];
  }
  if(h<=a){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200020],sum;
int main()
{
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    for(ll i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    reverse(a,a+n);
    ll t=n-1;
    for(ll i=0;i<n;i++)
    {
        if(!t) break;
        if(i==0)
        {
            sum+=a[i];
            t--;
        }
        else
        {
            sum+=a[i];
            t--;
            if(t) sum+=a[i],t--;
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 5172
#include<stdio.h>
int F[45];
void fib(int n){
  //if(n==0 || n==1)return 1;
  //return fib(n-1)+fib(n-2);
int i;
F[0]=1;
F[1]=1;
for(i=2;i<n+1;i++){
  F[i]=F[i-2]+F[i-1];
}
}
int main(){
  int n;
  scanf("%d",&n);
  fib(n);
  printf("%d\n",F[n]);
  return 0;
}



Measured memory_bytes: 2048
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var a = o.m(2);
  var d = a[1].reduce((a,b)=>a+b);
  var u = a[0][0];
  var ans = u + d;
  for(var i = 1; i < n; i++){
    u += a[0][i];
    d -= a[1][i-1];
    if(u + d > ans)ans = u + d;
  }
  return ans;
}

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    long double ans=0;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        int c=0,b=i;
        while(b<k){
            c++;
            b*=2;
        }
        ans+=pow(0.5,c)*(long double)(1.0/n);
    }
    cout<<fixed << std::setprecision(9)<<ans<<endl;
    return(0);
}

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

using namespace std;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef pair<int,int> pii;
typedef long long ll;
#define debug(x) cout << #x << "=" << x << endl;
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); cout << (i>0 ? " ":"") << v[i++]); cout << "\n"; return os;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, x;
    cin >> n >> m >> x;
    vi cst(n);
    vvi lvl(n, vi(m));
    int i,j;
    
    for(i=0;i<n;i++){
        cin >> cst[i];
        for(j=0;j<m;j++) cin >> lvl[i][j];
    }
    
    int ans = 1e9;
    int msk; 
    int T = 1<<n;

    for(msk = 0; msk < T; msk++){
        vb ok(n);
        for(j=0;j<n;j++) ok[j] = (msk & (1<<j));

        for(i=0;i<m;i++){
            int sm = 0;
            for(j=0;j<n;j++){
                if(ok[j]){
                    sm += lvl[j][i];
                }
            }
            if(sm < x) break;
        }
        if(i == m){
            int cc = 0;
            for(j=0;j<n;j++){
                if(ok[j]){
                    cc += cst[j];
                }
            }
            ans = min(ans, cc);
        }
    }
    if(ans == 1e9) ans = -1;
    
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3664
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
    int ans = 0;
	int d;
	cin >> d;
	if(d==7||d==5||d==3) cout << "YES" << endl;
	else cout  << "NO" << endl;
}

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

int main() {
    int n;
    while(cin >> n, n) {
        vector<string> s(n);
        for(int i = 0; i < n; ++i) {
            cin >> s[i];
        }

        int line = 0;
        function<int()> solve = [&]() {
            int cur_d = 0;
            for(auto c : s[line]) cur_d += c == '.';
            if(isdigit(s[line][cur_d])) {
                int res = 0;
                while(cur_d < (int)s[line].size()) {
                    res *= 10;
                    res += s[line][cur_d++] - '0';
                }
                return res;
            }
            const char op = s[line][cur_d];
            int res = op == '*';
            while(line < n) {
                int nxt_d = 0;
                line += 1;
                if(line >= n) break;
                for(auto c : s[line]) nxt_d += c == '.';
                if(nxt_d > cur_d) {
                    int t = solve();
                    if(op == '*') res *= t;
                    else          res += t;
                } else {
                    line--;
                    break;
                }
            }
            return res;
        };

        cout << solve() << endl;
    }
}



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

#define LL long long

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

int main(){
	

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n,x;
	cin>>n>>x;

	vector<int> v;
	for(int i=0;i<n;i++){
		int a;cin>>a;
		v.push_back(abs(a-x));
	}
	int g=0;
	for(int i=0;i<n;i++){
		g = gcd(g,v[i]);
	}
	cout<<g<<endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n, m;
    cin >> n >> m;
    map<int, int> mp;
    map<int, int> mpwrong;
    int wacount = 0;
    int account = 0;
    REP(i, m)
    {
        int p;
        string s;
        cin >> p >> s;
        if (mp.count(p) == 0)
        {
            if (s == "WA")
            {
                mpwrong[p]++;
            }
            else
            {
                account++;
                mp[p]++;
            }
        }
    }
    for (auto i : mpwrong)
    {
        if (mp.count(i.first) > 0)
        {
            wacount += i.second;
        }
    }
    cout << account << " " << wacount << endl;
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
#include <climits>

typedef long long ll;

using namespace std;

void printArray(int n, int *x){
    for(int i = 0; i < n; i++){
        cout << x[i];
        if(i < n-1){
            cout << " ";
        }
    }
    cout << endl;
}

void insertionSort(int *a, int n){
    for(int i = 1; i < n; i++){
        int v = a[i];
        int j = i-1;
        while(j >= 0 && a[j] > v){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        printArray(n, a);
    }
}

void solve(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    printArray(n, a);
    insertionSort(a, n);
}

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

Measured memory_bytes: 3092
n=int(input())
a=list(map(int,input().split()))
mod = 10**9+7

ans = 0
aa = 0
for i in range(n-1):
    aa += a.pop()
    # print(a,aa)
    ans +=  (aa * a[-1]) % mod
    ans %= mod

print(ans%mod)

Measured memory_bytes: 104872
from itertools import combinations
N = int(input())
L = list(map(int, input().split()))

def tri(a, b, c):
    l = [a,b,c]
    if (a == b or b == c) or c == a:
        return False
    x = min(l)
    l.pop(l.index(x))
    y = min(l)
    l.pop(l.index(y))
    z = l[0]
    if x + y > z:
        return True
    else:
        return False

count = 0

for x in list(combinations(L, 3)):
    a = x[0]
    b = x[1]
    c = x[2]
    if tri(a,b,c):
        count += 1

print(count)

Measured memory_bytes: 20592
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int n , m;

void solve()
{
	int n;
	cin >> n;

	loop(i,0,n)cin >> A[i];

	int ans = 0;

	loop(i,0,n)
	{
		loop(j,i+1,n)
		{
			loop(k,j+1,n)
			{
				if(A[i] != A[j] && A[j] != A[k] && A[i] != A[k] && A[i] + A[j] > A[k] && A[i] + A[k] > A[j] && A[j] + A[k] > A[i])
				{
					// cout << A[i] << " " << A[j] << " " << A[k] << endl;
					ans++;
				}
			}
		}
	}

	cout << ans;
}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

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

int a , b , c ;

int main(){

	cin >> a >> b >> c ;
  	
  	if( a == b && b == c) cout << 1 << endl;
  	else if(a == b && b != c) cout << 2 << endl;
  	else if(a != b && b == c) cout << 2 << endl;
   	else if(a == c && b != c) cout << 2 << endl; 
    else cout << 3 << endl;


}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
int n;
std::cin >> n;
int flag=0;
for (int i = 1; i < 10; i++) {
  for (int i2 = 0; i2 < 10; i2++) {
    if(i*i2==n){flag=1;break;}
  }
  if(flag==1)break;
}

if(flag==0)std::cout << "No" << '\n';
else std::cout << "Yes" << '\n';
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned int ll;
#define rep(i,n) for(int i=0;i<n;++i)
#define repf(i,n) for(int i=0;i<=n;i++)
const ll mod=1000000000+7;
typedef pair<ll, ll> P;

ll N,M;
priority_queue<ll,vector<ll>,greater<ll> > A;
ll dp[100010];

int main(){
	cin >> N >> M;
	rep(i,M){
		ll a;cin >> a;
		A.push(a);
	}

	dp[0] = 1; dp[1] = 1;
	ll cur;
	ll next;
	if(!(A.empty()))next = A.top();
	for(int i=1;i<N;i++){
		cur = next;
		if(!(A.empty())){
			next = A.top();
			if(i == next){
				dp[i] = 0;
				dp[i+1] = (dp[i] + dp[i-1]) % mod;
				A.pop();
				continue;
			}
			if(cur + 1 == next){
				cout << 0 << endl;
			}
		}

		dp[i+1] = (dp[i] + dp[i-1]) % mod;
	}

	cout << dp[N] << endl;
}

Measured memory_bytes: 1144
fun solve(n:Int, s:String){
    val alp = "abcdefghijklmnopqrstuvwxyz"
    var ans = ""

    for(i in 0 until s.length){
        val idx = alp.indexOf(s[i].toLowerCase())
        ans += alp[(idx+n)%26]
    }

    println(ans.toUpperCase())
}


fun main(){
    val n = readLine()!!.toInt()
    val s = readLine()!!
    solve(n,s)
}

Measured memory_bytes: 53520
S=list(input())
K=int(input())
l=[1]
for i in range(len(S)-1):
    if S[i]==S[i+1]:l[-1]+=1;
    else:l.append(1)
if len(l)==1:ans = len(S)*K//2;
else:
    l2=[i//2 for i in l]
    if S[0]==S[-1]:
        ht=(l[0]+l[-1])//2
        ans=l2.pop(0)
        ans+=l2.pop(-1)
        ans+=sum(l2)*K
        ans+=ht*(K-1)
    else:
        ans=sum(l2)*K
print(int(ans))
    


Measured memory_bytes: 3064
import bisect

n, *lst = map(int, open(0).read().split())
alst = sorted(lst[:n])
blst = lst[n:2*n]
clst = sorted(lst[2*n:])
res = 0
for i in blst:
  a = bisect.bisect_left(alst, i)
  c = n - bisect.bisect_right(clst, i)
  res += a * c
print(res)

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

int main() {
	string s;
	ll n;
	cin>>s>>n;
	for(int i=0;i<n;i++){
		if(s[i]!='1'){
			cout << s[i];
			return 0;
		}
	}
	cout << 1;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<queue>
#define ll long long
#define M 200010
#define mmp make_pair
using namespace std;
ll read() {
	ll nm = 0, f = 1;
	char c = getchar();
	for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
	for(; isdigit(c); c = getchar()) nm = nm * 10 + c - '0';
	return nm * f;
}
ll l, r, maxx, poww[M];
bool vis[M];
int main() {
	l = read(), r = read();
	if(l == r) {
		cout << 1;
		return 0;
	}
	poww[0] = 1;
	for(int i = 1; i <= 60; i++) poww[i] = poww[i - 1] << 1;
	int d = 60;
	while((l & poww[d]) == (r & poww[d])) d--;
	l &= poww[d + 1] - 1, r &= poww[d + 1] - 1;
	int k = d - 1;
	while(k >= 0 && !(r & poww[k]))k--;
	ll l1 = l, r1 = poww[d] + poww[k + 1] - 1, l2 = poww[d] + l, r2 = poww[d + 1] - 1;
	l2 = max(l2, r1 + 1);
	cout << r1 - l1 + 1 + max(0ll, r2 - l2 + 1) << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define intt long long
using namespace std;
int i ,  j;
intt a[200005];
int main ()
{
    int n;
    cin >> n;
    intt sum1 = 0,sum2=0,sum3=0;
    for ( i =1 ; i <= n ; i++ )
    {
        cin >> a[i];
        a[i]-=i;
    }
    sort(a+1,a+n+1);
    intt b1 = a[n/2] , maxx1 = 0, maxx2 = maxx1 , maxx3 = maxx1 , maxx4  = maxx1 ;
    intt b2 = a[(n/2)+1];
    intt b3 = a[ (n/2)-1 ];
    intt b4 = (a[(n/2)] + a[(n/2)-1] + a[(n/2)+1])/3;
    for ( int i = 1 ; i <= n ; i++ )
    {
        maxx1 += abs( a[i] - b1 );
        maxx2 += abs( a[i] - b2 );
        maxx3 += abs ( a[i] - b3 );
        maxx4 += abs( a[i]- b4 );
    }
    cout << min ( min(maxx1,maxx2) , min(maxx3,maxx4)) << endl;
    return 0;
}


Measured memory_bytes: 1920