akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"math/big"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Buffer(make([]byte, 0), 1e6) // maxTokenSize
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	/* --- code --- */
	INF := big.NewInt(1000000000000000000)

	n := nextInt()
	ans := big.NewInt(1)

	A := make([]int64, n)
	for i := 0; i < n; i++ {
		A[i] = nextInt64()
		if A[i] == 0 {
			fmt.Println(0)
			return
		}
	}

	for i := 0; i < n; i++ {
		a := big.NewInt(A[i])
		temp := new(big.Int).Mul(ans, a)
		if temp.Cmp(INF) == 1 {
			fmt.Println(-1)
			return
		}

		ans.Set(temp)
	}
	fmt.Println(ans)
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

func max(a, b int) int {
	return int(max64(int64(a), int64(b)))
}

func max64(a int64, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func min(a, b int) int {
	return int(min64(int64(a), int64(b)))
}

func min64(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a, b int) (ret int) {
	ret = a
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


Measured memory_bytes: 6256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    alp=list('ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ')
    n=INT()
    s=STR()
    ans=[]
    for i in s:
        ans.append(alp[alp.index(i)+n])
    print(*ans,sep='')
    
if __name__ == '__main__':
    do()

Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
int main() {
	map<int,int> a;
	for (int i = 0; i < 3; ++ i) {
		int u,v;
		cin >> u >> v;
		++ a[u];
		++ a[v];
	}
	bool ok = true;
	for (auto p : a) {
		if (p.second >= 3) ok = false;
	}
	cout << (ok ? "YES" : "NO") << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;


int main(int argc,char* argv[])
{
    ll a,b;
    cin>>a>>b;
    ll min_mod = INF;
    if(a>=b){
        cout<<0<<endl;
        return 0;
    }
    for(ll i = a; i < b;i++)
    {
        for(ll j = i + 1; j < b+1;j++)
        {
            min_mod = min(min_mod,(i*j)%2019);
            if(min_mod == 0)
            {
                cout<<0<<endl;
                return 0;
            }
        }
    }
    cout<<min_mod<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(x) x.begin(),x.end()
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define endl "\n"
const ll maxn = 2002;

ll power(ll x, ll y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  

int main()
{
    fastio; //remove for interactive
    ll i, j, k, n, m, t, mod=1e9+7;
    ll dp[maxn];
    memset(dp,sizeof(dp),0);

    dp[3]=1;
    for ( i = 4; i < maxn; i++)
    {
        dp[i]=((dp[i-3]%mod)+(dp[i-1]%mod))%mod;
    }

    cin >> n;

    if (n<3)
    {
        cout<<0<<endl;
        return 0;
    }
    if (n==3)
    {
        cout<<1<<endl;
        return 0;
    }

    cout<<dp[n]<<endl;


    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool chmax(T &a,const T &b){if(a<b){ a=b; return 1;}}
template<class T>bool chmin(T &a,const T &b){if(b<a){ a=b; return 1;}}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF 4000000000000000037 //1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){

  int N,K;
  cin>>N>>K;

  ll ans=INF;
  rep(i,pow(2,N)){
    int now=i;
    int num=1;
    rep(i,N){
      if(now>>i &1) num*=2;
      else num+=K;
    }
    ans=min(ans,(ll)num);
  }

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

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


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

using namespace std;

typedef unsigned long long ll;

struct Linear_basis {
  ll MN, a[65], tmp[65];
  void insert(ll x) {
    for(ll i = MN; ~i; i--) {
      if(x & (1ULL << i)) {
        if(!a[i]) { a[i] = x; return; }
        else x ^= a[i];
      }
      if(!i) break;
    }
  }
  ll qmax(ll res = 0) {
    for(ll i = MN; ~i; i--) {
        res = max(res, res ^ a[i]);
        if(!i) break;
    }
    return res;
  }
  Linear_basis() {
    memset(a, 0, sizeof(a));
    memset(tmp, 0, sizeof(tmp));
  }
} hhw;
const ll maxn = 1e5 + 5;
ll n, arr[maxn], cnt[65], ans;

int main() {
  scanf("%llu", &n); hhw.MN = 63;
  for(ll i = 1; i <= n; i++) scanf("%llu", &arr[i]);
  for(ll k = 0; k <= 63; k++)
    for(ll i = 1; i <= n; i++)
      cnt[k] ^= ((arr[i] >> k) & 1ULL);
  for(ll k = 0; k <= 63; k++) {
    if(!cnt[k]) continue;
    ans += (1ULL << k);
    for(ll i = 1; i <= n; i++)
      if((arr[i] >> k) & 1ULL)
        arr[i] ^= (1ULL << k);
  }
  for(ll i = 1; i <= n; i++)
    hhw.insert(arr[i]);
  ans += hhw.qmax() * 2ULL;
  printf("%llu\n", ans);
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, m, k;
  in2(n, m);
  if(abs(n - m) > 1){
    out(0);
    memi;
    return 0;
  }
  k = 1;
  if(n > m)
    swap(n, m);
  if(m == n + 1){
    rep(i, m)
      k = k * (i + 1) % mei;
    rep(i, n)
      k = k * (i + 1) % mei;
  }
  if(m == n){
    k = 2;
    rep(i, m)
      k = k * (i + 1) % mei;
    rep(i, n)
      k = k * (i + 1) % mei;
  }
  out(k);
  memi;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

void mainsolve(){

	string s;
	cin >> s;
	ll q;
	cin >> q;

	string mae = "";

	ll revcnt = 0;


	rep(i,q){
		ll t;
		cin >> t;
		if(t==1){
			revcnt++;

		}
		else{
			ll f;
			char c;
			cin >> f;
			cin >> c;
			if(f==1){
				if(revcnt % 2 == 1){
					s.push_back(c);
				}
				else{
					mae.push_back(c);
				}

			}
			else{
				if(revcnt % 2 == 1){
					mae.push_back(c);
				}
				else{
					s.push_back(c);
				}
				
			}

		}

	}

	if(revcnt % 2 == 1){
		reverse(s.begin(),s.end());
		
		cout << s + mae << endl;
	}
	else{
		reverse(mae.begin(),mae.end());
		cout << mae + s << endl;
	}

	return;
}

int main(){
	
//	ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 1248
n, q = map(int, input().split())
s = input()
a = [list(map(int, input().split())) for i in range(q)]

cum=[0]*n
for i in range(1, n):
    cum[i] = cum[i - 1]
    if s[i-1:i+1] == 'AC':
        cum[i]+=1

for i in range(q):
    print(cum[a[i][1]-1]-cum[a[i][0]-1])

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

int N;
int f(int a){
	int b = a * 2;
	if(b == N) return b;
	if(b > N) return a;
	return f(b);
}
int main() {
	cin >> N;
	if(N == 0) {
		cout << 0 << endl;
		return 0;
	}
	cout << f(1) << endl;

}




Measured memory_bytes: 3112
import java.io.*;

public class Main {
    public static void main(String[] args) {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
            String line = reader.readLine();
            String[] length = line.split(" ", -1);
            int a = Integer.parseInt(length[0]);
            int b = Integer.parseInt(length[1]);
            int x = a * b;
            int y = (a + b) * 2;
            System.out.println(x + " " + y);
        } catch (IOException e) {
            System.out.println(e);
        } catch (NumberFormatException e) {
            System.out.println("error");
        }
    }
}

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

using namespace std;

//dp[i][j]: The number of ways to distribute i candies 
// to first k children

//Initialization
//dp[0][0...N-1] = 1 and dp[i][0] = 1 if i<=ai

//Transitions
//dp[i][j] = dp[i][j-1] + dp[i-1][j-1] + ... + dp[i-A[j]][j-1]
//Use prefix_sums: prefix_sum[i] = dp[0][j-1] + dp[1][j-1] +...+ dp[i][j-1] 
//dp[i][j] = prefix_sum[i]-prefix_sum[i-A[j]-1]

//Order of evaluation
//Rowwise or Columwise

//Answer
//dp[K][N-1]

int dp[100005][105];
int A[105];
const int mod = 1e9+7;

int main(){
	int N, K;
	cin >> N >> K;
	for(int i=0; i<N; i++){
		cin >> A[i];
	}
    
    for(int j=0; j<N; j++){
        dp[0][j] = 1;
    }
    //cout << "Hey" << endl;
    for(int i=0; i<=K; i++){
        if(i>A[0]){
            dp[i][0] = 0;
        }
        else{
            dp[i][0] = 1;
        }
    }
    //cout << "Hey" << endl;
	for(int j=1; j<N; j++){
		
		vector<int> prefix_sum(K+1,0);
		int sum = 0;
		for(int i=0; i<=K; i++){
			sum = ((sum) % mod + (dp[i][j-1])% mod ) % mod;
			prefix_sum[i] = sum;
		}
		
		for(int i=1; i<=K; i++){
			if(i-A[j]-1>=0){
				dp[i][j] = ((prefix_sum[i]) % mod - (prefix_sum[i-A[j]-1]) % mod) % mod;
			}
			else{
				dp[i][j] = prefix_sum[i];
			}
		}
	
	}

	cout << (dp[K][N-1] + mod) % mod << endl;
}





Measured memory_bytes: 45036
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <stack>
#include <queue>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
#define ll long long
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int gcd(int x,int y){
    if(x%y==0)return y;
    gcd(y,x%y);
}

int main(){
    int n,start;
    cin >> n >> start;
    vector<int> x(n,0);
    rep(i,n){
        cin >> x[i];
    }
    rep(i,n){
        x[i] = abs(x[i]-start);
    }

    int ans=x[0];
    rep(i,n){
        ans = gcd(ans,x[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

int sum[2][400000];

int main()
{
    int n;
    string s;

    cin >> n >> s;

    rep(i, n) {
        sum[0][i+1] = sum[0][i];
        sum[1][i+1] = sum[1][i];
        if ( s[i] == 'E' ) sum[0][i+1] = sum[0][i] + 1;
        if ( s[i] == 'W' ) sum[1][i+1] = sum[1][i] + 1;
    }

    
    int ans = IINF;
    rep(i, n) {
        ans = min(ans, sum[1][i] + (sum[0][n] - sum[0][i+1]));
    }
    cout << ans << endl;
}


Measured memory_bytes: 3076
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> os;
 
 
const ll INF = 1e18;
const ll N =(4e5+5);
void solve(){
    string s;
    cin >> s;
    for(int i = 0;i<sz(s);i++){
        for(int j=i+1;j<sz(s);j++){
            if(s[i] == 'C' && s[j] == 'F'){
                cout << "Yes\n";
                return;
            }
        }
    }
    cout << "No\n";
}

signed main(){

    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    

 
     ll tt=1;   
    while(tt--){    
        solve();
    }    
}

Measured memory_bytes: 3660
// A Dynamic Programming based solution for 0-1 Knapsack problem 
#include<bits/stdc++.h>
using namespace std;

int max(int a, int b) { return (a > b)? a : b; } 
long int K[102][100005];
// Returns the maximum value that can be put in a knapsack of capacity W 
int knapSack(int W, int wt[], int val[], int n) 
{ 
int i, w; 
 

// Build table K[][] in bottom up manner 
for (i = 0; i <= n; i++) 
{ 
	for (w = 0; w <= W; w++) 
	{ 
		if (i==0 || w==0) 
			K[i][w] = 0; 
		else if (wt[i-1] <= w) 
				K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]], K[i-1][w]); 
		else
				K[i][w] = K[i-1][w]; 
	} 
} 

return K[n][W]; 
} 

int main() 
{ 
	int n,w;
	cin>>n>>w;
	int a[n+1],b[w+1];
	for(int i=0;i<n;i++) cin>>a[i]>>b[i];
	 knapSack(w, a, b, n);
	cout<<K[n][w];
	return 0; 
} 


Measured memory_bytes: 79104
#include <cstring>
#include <cstdio>

int main()
{
    char ch;
    int cnt[500];
    for (int i = 0; i < 500; i++){
        cnt[i] = 0;
    }

    while (scanf(" %c", &ch) != EOF){
        if (ch >= 'A' && ch <= 'Z'){
            ch += 'a' - 'A';
        }
        cnt[ch]++;
    }

    for (int i = 'a'; i <= 'z'; i++){
        printf("%c : %d\n", i, cnt[i]);
    }

    return 0;
}

Measured memory_bytes: 972
//update(s,t,x): a[s],a[s+1],...,a[t] をxに変更する
//find(s,t): a[s],a[s+1],...,a[t]の最小値を出力する

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

#define int long long
const int sqrtN = 512;
const int INF = (1LL << 31) - 1;

struct SqrtDecomposition{
    int N, K;
    vector<int> data;
    vector<int> bucketMin;
    vector<bool> lazyFlag;
    vector<int> lazyUpdate;
    SqrtDecomposition(int n):N(n){
        K = (N + sqrtN - 1) / sqrtN;
        data.assign(K * sqrtN, INF);
        bucketMin.assign(K, INF);
        lazyFlag.assign(K, false);
        lazyUpdate.assign(K, 0);
    }

    void eval(int k){
        if(lazyFlag[k]){
            lazyFlag[k] = false;
            for(int i = k * sqrtN; i < (k + 1) * sqrtN; i++){
                data[i] = lazyUpdate[k];
            }
        }
    }

    void update(int s, int t, int x){
        for(int k = 0; k < K; k++){
            int l = k * sqrtN;
            int r = (k + 1) * sqrtN;
            if(r <= s || t <= l) continue;

            if(s <= l && r <= t){
                bucketMin[k] = x;
                lazyFlag[k] = true;
                lazyUpdate[k] = x;
            }else{
                eval(k);
                for(int i = max(s, l); i < min(t, r); i++){
                    data[i] = x;
                }

                bucketMin[k] = INF;
                for(int i = l; i < r; ++i){
                    bucketMin[k] = min(bucketMin[k], data[i]);
                }
            }
        }
    }

    //[s, t)
    int find(int s, int t){
        int minVal = INF;
        for(int k = 0; k < K; k++){
            int l = k * sqrtN;
            int r = (k + 1) * sqrtN;
            if(r <= s || t <= l) continue;

            if(s <= l && r <= t){
                minVal = min(minVal, bucketMin[k]);
            }else{
                eval(k);
                for(int i = max(s, l); i < min(t, r); i++){
                    minVal = min(minVal, data[i]);
                }
            }
        }

        return minVal;
    }
};

signed main() {
    int N, Q; cin >> N >> Q;
    SqrtDecomposition decomp(N);
    while(Q--){
        int c; cin >> c;
        if(c == 0){
            int s, t, x; cin >> s >> t >> x;
            decomp.update(s, t + 1, x);
        }else{
            int s, t; cin >> s >> t;
            cout << decomp.find(s, t + 1) << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3592
/* it was worth becoming a chemist */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long unll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<int> vi;
typedef vector<long long> vll;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define NAME "puts"
#define F first
#define S second

const ll INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const db EPS = (db) 1e-9;
const db pi = acos(-1.0);
const int MAXN = 2e5 + 5;
   
string s;
int pos[30];
   
   
   
int main() {
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin >> s;
	
	int j = 0;
	for (auto i : s) {
		pos[i - 'a' ] = ++j;
	} 
		
	
	if (sz(s) != 26) {
		cout << s;
		for (char i = 'a'; i <= 'z'; i++) {
			if (pos[i - 'a'] == 0) {
				cout << i;
				return 0;
			}
		}
	}
	
	if (s == "zyxwvutsrqponmlkjihgfedcba") {
		cout << -1;
		return 0;
	}
	
	
	next_permutation(all(s));
	
	j = 0;
	for (auto i : s) {
		cout << i;
		if (pos[i - 'a'] != ++j) {
			break;
		}
	}

	
	return 0;
}	


Measured memory_bytes: 256
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

#define x first
#define y second

using namespace std;

typedef long long LL;
typedef pair<int,int>PII;

const int maxn = 2e5 + 10;

int a[maxn];

int t,n,m;

map<int,int>maps; 

int main(void) {
	scanf("%d",&n);
	for(int i = 1; i <= n; i ++) {
		scanf("%d",&a[i]);
	}
	LL ans = 0;
	for(int i = 1; i <= n; i ++) {
		if(maps.count(i - a[i]) != 0) {
			ans += maps[i - a[i]];
		}		
		maps[i + a[i]] ++;
	}
	cout << ans << endl;
	return 0;	
} 

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

public class Hello
{
    private const int MOD_N = 1000000000 + 7;

    public static void Main()
    {
        var list = Console.ReadLine().Split(' ');
        var n = int.Parse(list[0]);
        var l = int.Parse(list[1]);

        int sum = l * n;
        for (int i = 0; i < n; ++i)
            sum += i;

        if (l < 0)
        {
            var r = l + n - 1;
            if (r < 0)
            {
                sum -= r;
            }
        }
        else
        {
            sum -= l;
        }

        Console.WriteLine(sum);
    }

    private static int Comb(int m, int n)
    {
        var t = m - n;
        if (n > t)
            n = t;

        long numerator = 1;
        for (int i = 0; i < n; ++i)
        {
            numerator *= m - i;
            numerator %= MOD_N;
        }
        long denominator = 1;
        for (; n != 0; --n)
        {
            denominator *= n;
            denominator %= MOD_N;
        }

        var inv_denominator = ModInv((int)denominator, MOD_N);
        var ret = (int)(numerator * inv_denominator % MOD_N);

        return ret >= 0 ? ret : ret + MOD_N;
    }

    private static int ModInv(int a, int m)
    {
        int b = m, x = 1, y = 0;
        while (b != 0)
        {
            var t = a / b;
            a -= t * b;
            Swap(ref a, ref b);
            x -= t * y;
            Swap(ref x, ref y);
        }
        x %= m;
        return x >= 0 ? x : x + m;
    }

    private static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define ll  long long int
#define db long double 
#define ull unsigned long long int
// #define mp make_pair
#define F first
#define S second
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
#define Nmax 1000005
// #define INF 10000000000000
#define MOD 1000000007
#define MAXN 200005
 
using namespace std;

ll mod=1e9+7;
 
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}

const ll M=3000006;
ll f[M],inv[M];

void compute(){
    f[0]=1;
    rep(i,1,M-1){
        f[i]=(1LL*i*f[i-1])%mod;
    }
    inv[M-1]=expo(f[M-1],mod-2,mod);
    for(ll i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%mod;
    }
}
ll C(ll n,ll r){
    return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;
}

int main()
{
        ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    compute();
    int tests=1;
    // cin>>tests;    
    while(tests--)
    {
    	ll i,j,n;
    	cin>>n;
    	if(n==1) {cout<<0; return 0;}
    	ll ans=expo(10,n,mod);
    	ans-=expo(8,n,mod);
    	ans+=mod;
    	ans%=mod;
    	rep(i,1,n)
    	{
    		ans-=2LL*(C(n,i)*expo(8,n-i,mod))%mod;
    		ans+=mod;
    		ans%=mod;
    	}
    	cout<<ans;
    }

    return 0;
}
    

Measured memory_bytes: 50520
def resolve():
    N, A, B = list(map(int, input().split()))
    S = str(input())
    num = 0
    foreignnum = 1
    for i in range(N):
        if S[i] == 'a':
            if (num < A + B):
                num += 1
                print('Yes')
            else:
                print('No')

        if S[i] == 'b':
            if (num < A + B) and (foreignnum <= B):
                num += 1
                foreignnum += 1
                print('Yes')
            else:
                print('No')

        if S[i] == 'c':
            print('No')
    return
resolve()


Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, sum = 0;
  cin >> N;
  
  for(int i = 0; i < N; i++){
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
s = str(input())
for i in range(len(s)//2):
    if s[i] != s[-(i+1)]:
        print("No")
        exit()
for i in range(len(s)//4):
    if s[i] != s[(len(s)//2-i-1)]:
        print("No")
        exit()
for i in range(len(s) - (len(s)+3)//2):
    if s[(len(s)+3)//2+i-1] != s[-(i+1)]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val (a, b, c) = readLine()?.split(" ")?.map(String::toInt) ?: return

    val alreadyExists = hashMapOf<Int, Boolean>()
    1.until(101).forEach loop@{
        val r = (a * it) % b
        if (r == c) {
            println("YES")
            return
        }
        alreadyExists[r]?.let {
            return@loop
        }
        alreadyExists[r] = true
    }
    println("NO")
}

Measured memory_bytes: 37752
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 1e9;
const LL LLINF = 1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

struct city
{
    int index;
    int pref;
    int year;
    string name;

    city(int i, int p, int y): index(i), pref(p), year(y) {}
};

string last(string s, int n)
{
    string result=""s;
    REP1(i, n)
    {
        result = s[s.length() - i] + result;
    }
    return result;
}

void solve()
{
    int N, M; cin >> N >> M;
    vector<city> cities; cities.reserve(M);
    REP1(i, M)
    {
        int P, Y; cin >> P >> Y;
        city c(i, P, Y);
        cities.push_back(c);
    }

    auto sort_func_1 = [](city c1, city c2)
    {
        return (c1.pref == c2.pref) ? c1.year < c2.year : c1.pref < c2.pref;
    };

    sort(cities.begin(), cities.end(), sort_func_1);

    int num = 1;
    int prev_pref = 0;
    REP0(i, M)
    {
        if ( cities[i].pref != prev_pref ) { num = 1; prev_pref = cities[i].pref; }
        string zeros = "000000"s;
        cities[i].name = last(zeros + toString(cities[i].pref), 6) + last(zeros + toString(num), 6);
        num++;
    }

    auto sort_func_2 = [](city c1, city c2)
    {
        return c1.index < c2.index;
    };


    sort(cities.begin(), cities.end(), sort_func_2);

    REP0(i, M) cout << cities[i].name << endl;

}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

template<typename T>
struct SegmentTree{
    using F=function<T(T,T)>;
    
    int n;
    vector<T> dat;
    F f;
    T ti;
    
    SegmentTree(int n_ ,F f ,T ti) :f(f),ti(ti){
        n=1;
        while(n<n_) n*=2;
        dat.assign(2*n-1,ti);
    }
    
    SegmentTree(int n_ ,vector<T> &v ,F f,T ti) :f(f),ti(ti){
        n=1;
        while(n<n_) n*=2;
        dat.assign(2*n-1,ti);
        
        for(int i=n-1;i-(n-1)<v.size();i++) dat[i]=v[i-(n-1)];
        
        for(int i=n-2;i>=0;i--) dat[i]=f(dat[i*2+1],dat[i*2+2]);
    }
    
    void update(int k,T x){
        k+=n-1;
        dat[k]=x;
        
        while(k){
            k=(k-1)/2;
            dat[k]=f(dat[k*2+1],dat[k*2+2]);
        }
    }
    
    void set(int k,T x){
        dat[n-1+k]=x;
    }
    
    void built(){
        for(int i=n-2;i>=0;i--) dat[i]=f(dat[i*2+1],dat[i*2+2]);
    }
    
    T query_(int a,int b,int k,int l,int r){
        if(r<=a||b<=l) return ti;
        if(a<=l&&r<=b) return dat[k];
        else{
            T vl=query_(a,b,2*k+1,l,(l+r)/2);
            T vr=query_(a,b,2*k+2,(l+r)/2,r);
            return f(vl,vr);
        }
    }
    
    T query(int a,int b){
        return query_(a,b,0,0,n);
    }
    
    T get(int k){
        return dat[k+n-1];
    }
    
};

struct fn{
    ll a;
    ll lo;
    ll hi;
};

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll X,K;cin>>X>>K;
    vector<ll> ti(K+1,0);
    SegmentTree<fn> seg(K,
                        [](fn a,fn b){
                            fn ret;
                            ret.a=a.a+b.a;
                            ret.lo=min(max(a.lo+b.a,b.lo),b.hi);
                            ret.hi=min(max(a.hi+b.a,b.lo),b.hi);
                            return ret;
                        },
                        {0,-INF,INF});
    
    ll last=0;
    for(int i=0;i<K;i++){
        ll a;cin>>a;
        if(i%2==0) seg.update(i,{-(a-last),0,X});
        else seg.update(i,{a-last,0,X});
        last=a;
        ti[i+1]=a;
    }
    ti.push_back(INF);
    int Q;cin>>Q;
    
    while(Q--){
        ll a,b;cin>>a>>b;
        auto it=upper_bound(all(ti),a);
        it--;
        int d=it-ti.begin();
        
        fn f=seg.query(0,d);
        
        //cout<<f.a<<" "<<f.lo<<" "<<f.hi<<endl;
        
        //cout<<*it<<endl;
        
        ll c=min(max(b+f.a,f.lo),f.hi);
        
        if(d%2==0){
            cout<<max(c-(a-*it),0LL)<<"\n";
        }else{
            cout<<min(c+(a-*it),X)<<"\n";
        }
    }
}



Measured memory_bytes: 8176
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<db,db> pdb;
typedef tuple<int,int,int,int> TP;
typedef vector<vector<ll>> mat;
const int N=1e5+5;
const ll mod=1e9+7;
int n,s[N],t[N],ans;
int s2[N],t2[N];
map<int,int> cnt1,cnt2,par;
int fi(int x)
{
	if(par[x]==x) return x;
	return par[x]=fi(par[x]);
}
void un(int x,int y)
{
	x=fi(x); y=fi(y);
	if(x!=y) par[y]=x;
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>s[i];
	for(int i=1;i<=n;i++) cin>>t[i];
	for(int i=1;i<=n;i++){
		s[n+1]^=s[i];
		t[n+1]^=t[i];
	}
	for(int i=1;i<=n+1;i++) cnt1[s[i]]++;
	for(int i=1;i<=n+1;i++) cnt2[t[i]]++;
	for(int i=1;i<=n;i++) if(cnt2[t[i]]!=cnt1[t[i]]){
		cout<<-1;
		return 0;
	}
	bool ok=true;
	for(int i=1;i<=n+1;i++) if(s[i]!=t[i]) ok=false;
	if(ok){
		cout<<0;
		return 0;
	}
	for(int i=1;i<=n+1;i++){
		if(s[i]!=t[i]||i==n+1){
			if(i!=n+1) ans++;
			if(!par[s[i]]) par[s[i]]=s[i];
			if(!par[t[i]]) par[t[i]]=t[i];
			un(s[i],t[i]);
		}
	}
	for(auto &it : par) if(fi(it.fi)==it.fi) ans++;
	cout<<ans-1;
    return 0;
}

Measured memory_bytes: 15104
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int getdigit(int a) {
    if (a == 0) return 1;
    int cnt = 0;
    while(a) {
        cnt++;
        a /= 10;
    }
    return cnt;
}

int main() {
    int i, j;
    while(cin >> i >> j) {
        cout << getdigit(i+j) << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    IOS;
   // freopen("inputfile.txt","r",stdin);
   int n,k;cin>>n>>k;
   int ar[n];
   for(int i=0;i<n;i++)cin>>ar[i];
   int sum = 0;
   sort(ar,ar+n);
   int c = 0 ;
   while(k--)
   {
       sum+=ar[c];
       c++;
   }
   cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 3656
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>

using namespace std;
bool flag[200];
void solve()
{
	int n;
	while(cin >> n, n)
	{
		memset(flag, 0, sizeof(bool) * 2 * n);
		vector<int> Vec1(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> Vec1[i];
			flag[Vec1[i]] = 1;
		}
		sort(Vec1.begin(), Vec1.end());
		vector<int> Vec2;
		for(int i = 1; i <= 2 * n; ++i)
		{
			if(!flag[i])
			{
				Vec2.push_back(i);
			}
		}
		int count1 = 1;
		int count2 = 0;
		vector<int> Useflag(2 * n + 1);
		int num = Vec1[0];
		Useflag[Vec1[0]] = 1;
		int turn = 2;
		while(count1 < n && count2 < n)
		{
			if(turn == 1)
			{
				bool passflag = true;
				for(int i = 0; i < n; ++i)
				{
					if(num < Vec1[i] && Useflag[Vec1[i]] == 0)
					{
						num = Vec1[i];
						Useflag[Vec1[i]] = 1;
						count1++;
						passflag = false;
						break;
					}
				}
				if(passflag)
				{
					num = 0;
				}
				turn = 2;
			}
			else if(turn == 2)
			{
				bool passflag = true;
				for(int i = 0; i < n; ++i)
				{
					if(num < Vec2[i] && Useflag[Vec2[i]] == 0)
					{
						num = Vec2[i];
						Useflag[Vec2[i]] = 2;
						count2++;
						passflag = false;
						break;
					}
				}
				if(passflag)
				{
					num = 0;
				}
				turn = 1;
			}
		}
		cout << n - count2 << endl;
		cout << n - count1 << endl;
	}
}

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

Measured memory_bytes: 0
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
int h[100005],dp[100005];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d",&h[i]);
    dp[n-1]=0;
    dp[n-2]=abs(h[n-2]-h[n-1]);
    for(int i=n-3;i>=0;i--){
        dp[i]=min(dp[i+2]+abs(h[i]-h[i+2]),dp[i+1]+abs(h[i]-h[i+1]));
    }
    printf("%d\n",dp[0]);
    return 0;
}

Measured memory_bytes: 1024
const main=input=>{l=input.trim().split("\n");h=l[1].split(" ").map(e=>parseInt(e));r=new Array(h.length).fill(true);l.slice(2).map(e => e.split(" ").map(a => parseInt(a)-1)).map(e=>{a=h[e[0]],b=h[e[1]];(a==b?(r[e[0]]=r[e[1]]=!1):a<b?(r[e[0]]=!1):(r[e[1]]=!1))});return r.filter(e=>e).length};console.log(main(require('fs').readFileSync('/dev/stdin', 'utf8')))

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,c; cin >>a>>b >>c;
  cout << max(0ll,c - (a-b)) << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[2333333];
int main()
{
	int all,n,p=0,q=0;scanf("%d%d",&all,&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if (a[i]&1)
		{
			if (!p) p=i;
			else if (!q) q=i;
			else {printf("Impossible\n");return 0;}
		}
	}
	if ((n==1)&&(a[1]==1)) {printf("%d\n%d\n%d",1,1,1);return 0;}
	if (n==1) {printf("%d\n%d\n%d %d",a[1],2,a[1]-1,1);return 0;}
	if (p) swap(a[p],a[1]);
	if (q) swap(a[q],a[n]);
	for (int i=1;i<=n;i++) printf("%d ",a[i]);printf("\n");
	if (a[1]!=1)
	{
		printf("%d\n",n);
		printf("%d ",a[1]-1);
		for (int i=2;i<n;i++) printf("%d ",a[i]);
		printf("%d ",a[n]+1);
	}
	else
	{
		printf("%d\n",n-1);
		for (int i=2;i<n;i++) printf("%d ",a[i]);
		printf("%d ",a[n]+1);	
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll r;
    cin>>r;
    cout<<r*r<<endl;
}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  int x=1;
  for(int i=0;i<N;i++){
    if(x*2>x+K)x+=K;
    else x*=2;
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}


const int N_MAX = 51, M_MAX = 51;
int N,M;
vector<vector<char> > A(N_MAX, vector<char>(N_MAX));
vector<vector<char> > B(M_MAX, vector<char>(M_MAX));
bool check(int i, int j){
  bool iscontain = true;
  rep(k,M)rep(l,M) if(A[i+k][j+l] != B[k][l]) iscontain = false;
  return iscontain;
}


int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> N >> M;
  rep(i,N)rep(j,N)cin >> A[i][j];
  rep(k,M)rep(l,M)cin >> B[k][l];
  bool iscontain = false;
  rep(i,N-M+1)rep(j,N-M+1){
    if(check(i,j)) iscontain = true;
  }
  YesNo(iscontain);
  return 0;
}


Measured memory_bytes: 256
N, K = map(int,input().split())
A = list(map(int,input().split()))
tentou = [0 for i in range(N)] #tentou[i]はA[i]>A[j]なるjの数(i < j)
compl = [0 for i in range(N)] #compl[i]はA[i] > A[j]なるjの数(i != j つまりi < jとは限らない)
for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            compl[i] += 1
            if i < j:
                tentou[i] += 1
print(str((sum(tentou)*K + sum(compl)*K*(K-1)//2) % (10**9+7)))

Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;


int main()
{

char c;
cin>>c;
   if (c == 'a' || c == 'e' || c == 'i' ||
   c == 'o' || c == 'u')
   cout<<"vowel" << endl;
   else
   cout<<"consonant";













return 0;
}


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

int main(){
  int n;
  cin >> n;
  
  vector<int64_t> lucas(n+1);
  lucas.at(0)=2;
  lucas.at(1)=1;
  rep2(i,2,n+1)
    lucas[i] = lucas[i-1] + lucas[i-2];
  
  cout << lucas[n] << endl;
}
  


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

using namespace std;

#define int 		long long
#define ld			double
#define endl		"\n"
#define mod			1000000007
#define inf			1e12
#define IOS			ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int32_t main() {

	IOS;

	int n;
	cin >> n;

	vector<int> v(4, 0);

	for (int i = 0; i < n; i++) {
		cin >> v[0];
		v[v[0]]++;
	}
	int mx = 302;

	ld dp[mx][mx][mx];

	for (int c = 0; c < mx; c++) {
		for (int b = 0; b < mx; b++) {
			for (int a = 0; a < mx; a++) {
				ld k = a + b + c;
				if (k > mx || k == 0)
					continue;

				if (a) {
					dp[a][b][c] += dp[a - 1][b][c] * a / k;
				}
				if (b) {
					dp[a][b][c] += dp[a + 1][b - 1][c] * b / k;
				}
				if (c) {
					dp[a][b][c] += dp[a][b + 1][c - 1] * c / k;
				}

				dp[a][b][c] += n / k;
			}
		}
	}

	cout << setprecision(12) << dp[v[1]][v[2]][v[3]] << endl;

	return 0;
}

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

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

int X, A, B;
int main(void){

	cin >> X;
	cin >> A;
	cin >> B;

	int ans = X;
	ans -= A;
	ans = ans % B;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
using ll = long long;
const int INF = 0x3f3f3f3f;
const int MAX_N = 2000006;

int N;

void solve()
{
	cout << (ll)pow(N, 3) << endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N;
	solve();
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <chrono>
#include <assert.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

const int N = 10;
bool visited[N];
vector<ll> vals;
ll cost[N][N];
int n, j;

void dfs(int i, ll s) {
	visited[i] = true;
	int outs = 0;
	for (int t = 0; t < n; ++t) {
		if (! visited[t]) {
			++outs;
			dfs(t, s + cost[i][t]);
		}
	}
	if (outs == 0 && i > j) vals.push_back(s);
	visited[i] = false;
}

bool works() {
	for (j = 0; j+1 < n; ++j) dfs(j, 0);
	sort(vals.begin(), vals.end());

	bool ans = true;
	for (int i = 0; i+1 < vals.size(); ++i) {
		if (vals[i] == vals[i+1]) ans = false;
	}
	vals.clear();
	return ans;
}

// rand-function that works properly on windows, and is faster than rand
// https://codeforces.com/blog/entry/61587
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>
T rand(T a, T b) {
	return uniform_int_distribution<T>(a, b)(rng);
}

const ll MAX_V = 1e10;

ll log2(int v) {
	int res = 1;
	while(v > 1) {
		v /= 2;
		++res;
	}
	return res;
}

// Find 9 numbers s.t. their sum is distinct
int main() {
	vector<vector<int>> xr = {
	{1},
	{1,2},
	{1,2,4},
	{1,2,4,7},
	{1,2,4,7,12},
	{1,2,4,8,13,18},
	{1,2,4,8,14,19,24},
	{1,2,4,8,15,24,29,34},
	{1,7,10,13,21,26,41,43,45}
	};

	cin >> n;
	while(true) {
		ll b = 1;
		for (int i = 0; i+1 < n; ++i) {
			int ln = n-1-i;
			for (j = i+1; j < n; ++j) {
				cost[i][j] = b * xr[ln-1][j-1-i];
				cost[j][i] = cost[i][j];
			}
			if (ln >= 2) b *= (1+xr[ln-1][ln-1]+xr[ln-1][ln-2]);
		}
		/*
		for (int i = 0; i < n; ++i) {
			for (j = i+1; j < n; ++j) {
				if (rand(0, 1)) cost[i][j] = rand(1ll, MAX_V);
				cost[j][i] = cost[i][j];
			}
		}
		*/
		if (works()) {
			for (int i = 0; i < n; ++i) {
				for (j = 0; j < n; ++j) {
					cout << cost[i][j] << ' ';
				}
				cout << '\n';
			}
			break;
		}
	}
}







Measured memory_bytes: 18280
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;


int main(){
    int k;
    cin >> k;
    int ans = 0;
    rep(i, k) rep(j, k) rep(l, k) {
        ans += gcd(i+1, gcd(j+1, l+1));
    }
    
    
    
    cout << ans << endl;
    return 0;
}


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

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>(1e6) + 17;

int n, m, a, b;
ll fac[MAXN];

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

    return true;
}

ll binpow(ll a, ll n) {
    ll res = 1ll;

    for (; n > 0; n /= 2, a = a * a % INF)
        if (n & 1)
            res = res * a % INF;

    return res;
}

ll rev(ll x) { return binpow(x, INF - 2); }

ll binomial(int n, int k) {
    return fac[n] * rev(fac[k] * fac[n - k] % INF) % INF;
}

void solve() {
    fac[0] = 1;

    forn (i, MAXN - 1)
        fac[i + 1] = (i + 1) * fac[i] % INF;

    int j = b - 1;
    ll ans = 0;

    for (int i = 0; i + a < n; ++i) {
        ans += binomial(i + j, i) * binomial(n - i + m - j - 3, n - i - 1);
        ans %= INF;
    }

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 8064
import math

a, b, C = map(float,input().split())

S = 0.5 * a * b * math.sin(math.radians(C))
l = (a**2 + b**2 - 2*a*b*math.cos(math.radians(C)))**0.5 + a + b
h = (2 * S) / a

print(S)
print(l)
print(h)



Measured memory_bytes: 5700