akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 60;
constexpr auto mod = 1000000007;
constexpr auto MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

ll c[51][51] = {};

int main() {

    int n, a, b;
    ll v;
    cin >> n >> a >> b;
    map<ll, int> m;
    FOR(i, 0, n) {
        cin >> v;
        m[v]++;
    }

    vector<ll> d;
    for (auto i : m)d.push_back(i.first);
    rSORT(d, [](ll a, ll b) {return a > b; });
    double ave = 0;

    int cnt = a, itr = 0;
    if (m[d[0]] > a)ave = d[0];
    else {
        while (1) {
            if (cnt <= m[d[itr]]) {
                ave += d[itr] * cnt;
                break;
            }
            else {
                ave += d[itr] * m[d[itr]];
                cnt -= m[d[itr++]];
            }
        }
        ave /= a;
    }
    printf("%.11lf\n", ave);

    eFOR(i, 0, n)eFOR(j, 0, i) {
        if (j == 0 || j == i)c[i][j] = 1LL;
        else c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]);
    }

    ll ans = 0;
    if (d[0] != d[itr]) {
        ans = c[m[d[itr]]][cnt];
    }
    else eFOR(i, a, min(m[d[0]], b))ans += c[m[d[0]]][i];
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int n, a, b;
int main() {
	cin >> n;
	int curm = 0, ret = 0;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		if (curm < a) {
			ret = a + b;
			curm = a;
		}
	}
	cout << ret << endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))

d={}
for i in range(N):
    if A[i] in d:
        d[A[i]]+=1
    else:
        d[A[i]]=1

ans=sum(A)
Q=int(input())

for _ in range(Q):
    b,c=map(int,input().split())
    if b in d:
        ans+=(c-b)*d[b]
        if c in d:
            d[c]+=d[b]
        else:
            d[c]=d[b]
        d.pop(b)
    print(ans)


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

using namespace std;

int main() {
  int n, o = 0;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
    o += a.at(i) - 1;
  }
  cout << o << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

const int MOD = 1e9+7;

long long cnt[10001][2][100];

void addMod(long long* a, long long b){
  *a = (*a + b) % MOD;
}

int main(){

  string K;
  cin >> K;
  int D;
  cin >> D;

  memset(cnt, 0, sizeof(cnt));

  cnt[0][0][0] = 1;

  int sizeK = (int) K.size();
  for(int i = 1; i <= sizeK; i++){
    int digit = K[i - 1] - '0';
    
    for(int j = 0; j < D; j++){
      for(int k = 0; k < 10; k++){
	int nextState = (j + k) % D;
	if(k < digit){
	  addMod(&cnt[i][1][nextState], cnt[i - 1][0][j] + cnt[i - 1][1][j]);
	}
	else if(k == digit){
	  addMod(&cnt[i][0][nextState], cnt[i - 1][0][j]);
	  addMod(&cnt[i][1][nextState], cnt[i - 1][1][j]);
	}
	else{
	  addMod(&cnt[i][1][nextState], cnt[i - 1][1][j]);
	}
      }
    }
  }

  cout << (cnt[sizeK][0][0] + cnt[sizeK][1][0] + MOD - 1) % MOD << endl;
  
  return 0;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
	
int main(){
	int A, B;
	cin >> A >> B;
	int ans = A + B;
	if(ans < 10) cout << ans << endl;
	else cout << "error" << endl;
}

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

int main(int argc, const char * argv[]) {
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);

    /////////////////////
    // Write code below /
    /////////////////////

    int a, b, c;
    bool result = false;

    cin >> a >> b >> c;

    if (a + b == c) {
        result = true;
    } else if (a + c == b) {
        result = true;
    } else if (b + c == a) {
        result = true;
    }

    if (result) {
        cout << "Yes";
    } else {
        cout << "No";
    }

    return 0;
}

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

int N,ans[251000] = {0};
pair<int,int> X[510];
int main(){
	cin >> N;
	int x;
	for(int i=1;i<=N;i++){
		cin >> x;
		X[i] = {x,i};
		ans[x] = i;
	}
	sort(X+1,X+N+1);
	int id = 1;
	bool judge = true;
	for(int i=1;i<=N;i++){
		int count = 0;
		while(count<X[i].second-1){
			if(ans[id]==0){
				ans[id] = X[i].second;
				count++;
			}
			id++;
		}
	}
	id = N*N;
	for(int i=N;i>=1;i--){
		int count = 0;
		while(count<N-X[i].second){
			if(ans[id]==0){
				ans[id] = X[i].second;
				count++;
			}
			id--;
		}
	}
	int c[510] = {0},num = 1;
	for(int i=1;i<=N*N;i++){
		c[ans[i]]++;
		if(i==X[num].first){
			if(c[X[num].second]!=X[num].second) judge = false;
			num++;
		}
	}
	if(!judge){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	for(int i=1;i<=N*N;i++){
		cout << ans[i] << (i!=N*N? " ":"\n");
	}
}


Measured memory_bytes: 2176
#include <iostream>

 

using namespace std;

 

int main()
{
    int a ,b, c, i;
    for(i=1; i<=3000; i++)
    {
        cin >> a >> b;
        if(a == 0 && b == 0)
            break;

        if ( a > b)
        {
            c = a;
            a = b;
            b = c;
        }
       cout << a << " " << b << endl;
    }
}


Measured memory_bytes: 3024
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a + b + 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
# classを使うのをやめてlistで実施する
from collections import deque
import sys
sys.setrecursionlimit(10 ** 9)
import sys
input = sys.stdin.readline

def dfs(v):
    visited[v] = True
    for i in range(len(AL[v][CHILDREN])):
        u = AL[v][CHILDREN][i]
        if visited[u]:
            AL[v][CHILDREN][i] = None
            continue
        AL[v][SIZE] += dfs(u)
    return AL[v][SIZE]


def anaaki(v):
    ret = powp - 1
    for ch in AL[v][CHILDREN]:
        if ch is None: continue
        ret -= pow(2, AL[ch][SIZE], p) - 1
        ret %= p
    ret -= pow(2, n - AL[v][SIZE], p) - 1
    ret %= p
    return ret

n = int(input())
SIZE = 0
CHILDREN = 1
AL = [[1, []] for _ in range(n)]
visited = [False] * n
p = 10 ** 9 + 7
powp = pow(2, n - 1, p)

for i in range(n - 1):
    a, b = [int(x) - 1 for x in input().split()]
    AL[a][CHILDREN].append(b)
    AL[b][CHILDREN].append(a)

dfs(0)
numer = 0
for i in range(n):
    numer += anaaki(i)
    numer %= p

denom = pow(2, n, p)
print(numer * pow(denom, p - 2, p) % p)

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

int main() {
  vector<int> A(3);
  rep(i, 3) cin >> A.at(i);
  
  sort(A.begin(), A.end());
  if(A.at(0)==A.at(1) && A.at(0)!=A.at(2)) cout << "Yes" << endl;
  else if(A.at(1)==A.at(2) && A.at(0)!=A.at(1)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}




Measured memory_bytes: 3612
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] In = Console.ReadLine().Split(' ');
            int a = int.Parse(In[0]);
            int b = int.Parse(In[1]);
            int t = int.Parse(In[2]);
            int times = t / a;
            Console.WriteLine(b * times);
        }
    }
}


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

int main() {
  long long N, K, Q;
  cin >> N >> K >> Q;
  
  vector<long long> C(N);
  vector<long long> A(Q);
  
  for (int i = 0; i < Q; i++) {
    cin >> A[i];
    C[A[i]-1]++;
  }
  
  for (int i = 0; i < N; i++) {
    long long point = K - Q + C[i];
    if (point <= 0) { cout << "No" << endl; }
    else { cout << "Yes" << endl; }
  }
 
  return 0;
}

Measured memory_bytes: 2176
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define Reverse(x) reverse(all(x));
#define Sort(x) sort(all(x));
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    string s;
    cin >> s;
    if(s.size()==3)
    {
        Reverse(s);
    }
    out(s);
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int n,ara[1002][1002],i,j;
int main()
{

string s1,s2;
cin>>s1>>s2;
int s=0;
for(int i=0;i<s1.size();i++)
{
    if(s1[i]==s2[i])s++;
}
cout<<s<<endl;
return  0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
#define ABS(X) (((X)>=0)?(X):(-(X)))
 
int main () {
  int N;
  int W[101];
  int min=100;
  W[0] = 0;
  cin >> N;
  for (int i=1; i<=N; i++) {
    int tmp;
    cin >> tmp;
    W[i] = W[i-1] + tmp;
  }
  for (int i=1; i<=N; i++) {
    int tmp = ABS(W[N]-2*W[i]);
    if (tmp<min)
      min=tmp;
  }
  cout << min << endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <unordered_map>

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

#define ff first
#define ss second

const long long maxn = 1e4 + 1;
const long long MOD = 1e9 + 7;

long long mod_pow(long long a, long long b, long long p = MOD) { // = (a^b) % p //((a^-1) % p) = (a^(p-2)) % p;
	long long res = 1;
	a %= p;

	while (b > 0) {
		if ((b & 1) == 1) res = ((res % p) * (a % p)) % p;
		a = ((a % p) * (a % p)) % p;
		b >>= 1;
	}
	return res;
}

vector<bool> is_prime(maxn, true);
void sieve() {
	for (long long i = 2; i * i < maxn; i++) {
		if (is_prime[i] == true) {
			for (long long j = i * i; j < maxn; j += i) is_prime[j] = false;
		}
	}
	is_prime[0] = false;
	is_prime[1] = false;
	return;
}

long long  n;
vector<long long > a;

long long  __lcmMOD() {
	unordered_map<long long, long long> max_pow;

	for (auto i : a) {
		unordered_map<long long, long long> pfac;
		for (long long fac = 2; fac * fac <= i; fac++) {
			if (is_prime[fac] and i % fac == 0) {
				while (i % fac == 0) {
					pfac[fac]++, i /= fac;
					max_pow[fac] = max(max_pow[fac], pfac[fac]);
				}
			}
		}
		if (i > 1) pfac[i]++, max_pow[i] = max(max_pow[i], pfac[i]);;
	}

	long long  l = 1;
	for (auto i : max_pow) {
		l = (l % MOD * mod_pow(i.ff, i.ss)) % MOD;
	}
	return l;
}

int  main() {

	sieve();
	cin >> n;
	a.resize(n);
	for (long long  i = 0; i <= n - 1; i++) cin >> a[i];

	long long  k = __lcmMOD();

	long long  ans = 0;
	for (auto i : a) ans = (ans % MOD + (k % MOD * mod_pow(i, MOD - 2)) % MOD) % MOD;

	cout << ans % MOD;

	return 0;
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 20100;

class block {
public:
	ll w, s, v;
};

class comparator {
public:
	bool operator()(block a, block b) {
		return a.w + a.s < b.w + b.s;
	}
};

block a[maxn];
int n;

ll dp[1010][maxn];

int main() {
	cin>>n;

	ll w, s, v;
	for(int i=1;i<=n;i++) {
		cin>>w>>s>>v;
		a[i] = {w, s, v};
	}

	sort(a+1, a+n+1, comparator());

	ll result = 0LL;
	for(int i=1;i<=n;i++) {
		for(int j=0;j<maxn;j++) {
			dp[i][j] = dp[i-1][j];
			if(j - a[i].w >= 0 && a[i].s >= j - a[i].w) {
				dp[i][j] = max(dp[i][j], dp[i-1][j-a[i].w] + a[i].v);
			}
			result = max(result, dp[i][j]);
		}
	}
	cout<<result;
}

Measured memory_bytes: 157824
N = int(input())
if N<=1000:
    print(1000-N)
elif N<=2000:
    print(2000-N)
elif N<=3000:
    print(3000-N)
elif N<=4000:
    print(4000-N)
elif N<=5000:
    print(5000-N)
elif N<=6000:
    print(6000-N)
elif N<=7000:
    print(7000-N)
elif N<=8000:
    print(8000-N)
elif N<=9000:
    print(9000-N)
elif N<=10000:
    print(10000-N)


Measured memory_bytes: 9132
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;

//#[proconio::fastout]
fn main() {
    input! {
        n: usize,
        s: Bytes,
    }

    let mut r = Vec::with_capacity(n);
    let mut g = Vec::with_capacity(n);
    let mut b = Vec::with_capacity(n);

    for i in 0..n {
        match s[i] {
            b'R' => r.push(i),
            b'G' => g.push(i),
            b'B' => b.push(i),
            _ => panic!(),
        }
    }

    let mut ans = r.len() as u64 * g.len() as u64 * b.len() as u64;
    for ri in 0..r.len() {
        for gi in 0..g.len() {
            let rpos = r[ri] as i64;
            let gpos = g[gi] as i64;
            let bpos1 = rpos - (rpos - gpos) * 2;
            let bpos2 = gpos - (gpos - rpos) * 2;
            if 0 <= bpos1 && bpos1 < n as i64 && s[bpos1 as usize] == b'B' {
                ans -= 1;
            }
            if 0 <= bpos2 && bpos2 < n as i64 && s[bpos2 as usize] == b'B' {
                ans -= 1;
            }
            if (rpos + gpos) % 2 == 0 {
                let bpos3 = (rpos + gpos) / 2;
                if s[bpos3 as usize] == b'B' {
                    ans -= 1;
                }
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 2184
// -*- coding:utf-8-unix -*-

use proconio::input;
use proconio::marker::Usize1;


fn main() {
	input! {
		n : usize,
		k : usize,
		d : [[Usize1]; k]
	}
	let mut cnt = vec![1 as u32; n];
	for dd in d {
		for ddd in dd {
			cnt[ddd] = 0;
		}
	}
	println!("{}", cnt.iter().sum::<u32>());
}


Measured memory_bytes: 2228
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;


NodePointer nil; /*??°?????????????????°*/


/*????????????????´¢????????¢??°*/
NodePointer listSearch(int key){
  /* your code */
  NodePointer tmp;
  tmp = nil->next;

  
  while(1){
    if(tmp->key == key)return tmp;
    if(tmp == nil)return 0;
    tmp = tmp->next;
  }

  
}



void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}


/*??¨???????????¢??°*/
void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

/*?????????????¶????(???????????????)*/
void deleteNode(NodePointer t){

  /* your code */
  t->prev->next = t->next;
  t->next->prev = t->prev;
  
  free(t);
}

/*??????????????????????´?????¶????*/
void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}


/*????????????????°?????¶????*/
void deleteLast(){
  /* your code */
  NodePointer t = nil->prev;
  if( t == nil)return;
  deleteNode(t);
}


/*deleteNode??¢??°????????¶*/
void delete(int key){
  /* your code */
  NodePointer tmp;

  tmp =  listSearch(key);
  
  if(tmp == NULL)return;
  deleteNode(tmp);
  
}

/*????´?????????\*/
void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  /* your code */
  nil->next->prev = x;
  x->next = nil->next;
  nil->next = x;
  x->prev = nil;

}


int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init(); /*?????????*/
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}

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


int main() {
    int n,sum;
    cin>>n;
	int w[n];
	w[0]=0;
	for(int i=1;i<=n;i++){
        cin>>w[i];
        w[i]+=w[i-1];
	}

	int ans=abs(w[1]-(w[n]-1));
	for(int i=1;i<=n;i++){
        if(abs(w[i]-(w[n]-w[i]))<=ans){
            ans=abs(w[i]-(w[n]-w[i]));
        }
	}
	cout<<ans;
	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int N, P;
    cin >> N >> P;
    ll cnt[2] = {0,0};
    for(int i=0; i<N; i++){
        int a;  cin >> a;
        cnt[a%2]++;
    }

    if(cnt[1]==0){
        if(P==1) cout << 0 << endl;
        else cout << (ll)pow(2,N) << endl;
    }else{
        cout << (ll)pow(2, N-1) << endl;
    }
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] A = new int[n];
		Arrays.setAll(A, i -> sc.nextInt());
		Arrays.sort(A);
		boolean[] dp = new boolean[1000001];
		for (int i = 1; i < n; i++) {
			if (A[i] == A[i - 1]) {
				if (!dp[A[i]]) {
					for (int j = A[i]; j < 1000001; j += A[i]) {
						dp[j] = true;
					}
				}
			}
		}
		long ans = 0;
		for (int i = 0; i < n; i++) {
			if (!dp[A[i]]) {
				ans++;
				for (int j = A[i]; j < 1000001; j += A[i]) {
					dp[j] = true;
				}
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 61456
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef long long LL;
#define REPD(i,a,b) for (LL i=(a);i<(b);i++)
#define REP(i,n) REPD(i,0,n)

using namespace std;


LL inputValue(){
  LL a;
  cin >> a;
  return a;
};

vector<LL> inputVector(LL a){
  vector<LL> rv;
  REP(i, a){
    LL input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}

vector<string> inputVectorString(LL a){
  vector<string> rv;
  REP(i, a){
    string input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}

#if 0
#define debug(d) debug1(__LINE__,#d, d)
void debug1(LL line, const char* name, vector<LL>& v) {
  cout << line << ":" << name << ":vector<LL>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, LL i) {
  cout << line << ":" << name << ":LL " << i << endl;;
}
void debug1(LL line, const char* name, vector<string>& v) {
  cout << line << ":" << name << ":vector<string>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
#else
#define debug(n)
#endif

int main(int argc, const char * argv[]) {
  // source code
  LL n = inputValue();
  vector<string> ss = inputVectorString(n);
  debug(ss);
  REP(i, n) {
    sort(ss[i].begin(), ss[i].end());
  }
  sort(ss.begin(), ss.end());
  debug(ss);
  LL count = 0;
  string* cur = &ss[0];
  LL ccount = 0;
  REPD(i, 1, n) {
    if (*cur == ss[i]) {
      ccount++;
    } else {
      debug(i);
      debug(ccount);
      debug((ccount*(ccount+1))/2);
      count+=(ccount*(ccount+1))/2;
      debug(count);
      cur = &ss[i];
      ccount = 0;
    }
  }
  count+=(ccount*(ccount+1))/2;
  cout << count << endl;


  return 0;
}


Measured memory_bytes: 7284
#include <iostream>
//#include <cstdio>

//int main(int argc, const char * argv[]) {
int main() {
    int a, b, c, d;
    std::cin >> a >> b;
    c = a * b;
    d = a * 2 + b * 2;
    std::cout << c << " " << d << "\n";
    return 0;
}

Measured memory_bytes: 3100
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

H, W = list(map(int, input().split()))
# 多次元配列の宣言（あとでintにすること。）（タプルにすること。）
A = [""]*H 
#INF = np.Inf
INF = 2000

#D = np.zeros((H+1, W+1))
D = [[0]*(W+1) for h in range(H+1)]

for h in range(H):
    A[h] = input()
    for w in range(W):
        if A[h][w] == '.':
            D[h][w] = 1           

def main(): 
    #G = np.zeros((H+1, W+1))
    #T = np.zeros((H+1, W+1)) # 自分以外横に何マスつながっているか
    #Y = np.zeros((H+1, W+1)) # 自分以外縦に何マスつながっているか
    T = [[0]*(W+1) for h in range(H+1)]
    Y = [[0]*(W+1) for h in range(H+1)]
    
    for h in range(H):
        cnt = 0
        for w in range(W):
            if D[h][w] == 0:
                cnt = 0
                continue
            else:
                Y[h][w] += cnt
                cnt+=1    
    for h in range(H):
        for w in reversed(range(W)):
            if D[h][w] == 0:
               continue
            else:
               Y[h][w] = max(Y[h][w], Y[h][w+1])                           
            
    for w in range(W):
        cnt = 0
        for h in range(H):
            if D[h][w] == 0:
                cnt = 0
                continue
            else:
                T[h][w] += cnt
                cnt+=1
    for w in range(W):
        for h in reversed(range(H)):
            if D[h][w] == 0:
                continue
            else:
                T[h][w] = max(T[h][w], T[h+1][w])
    #G = D+Y+T
    #res = np.amax(G)
    res = 0
    for w in range(W):
        for h in range(H):
            res = max(res, D[h][w]+Y[h][w]+T[h][w])
    print(int(res))
            
            
                

    
if __name__ == '__main__':
    main()


Measured memory_bytes: 149000
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int  n, s=1, p=pow(10,18) ; 
    bool flag=false;
    cin >> n ; 
    int a[n];
    for (int i=0;i<n;i++) cin >> a[i] ; 
    sort(a,a+n) ; 
    int i=0;
    while (i<n){
        if ( a[i]>0 and s>0 and (p/a[i] < s) ) {
            cout << -1 << endl;
            return ; 
        }
        s *= a[i];
        i++;
    }
    cout << s <<endl;
    
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 4392
#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#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 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    int N,M;
    cin >> N >> M;
    vector<ll> A(N);
    vector<vector<ll>> BC(M, vector<ll>(2));
    REP(i,N){
        cin >> A[i];
    }
    REP(i,M){
        cin >> BC[i][1] >> BC[i][0];
    }
    sort(&BC[0], &BC[M], [](auto& x, auto& y){return x[0] > y[0];});
    VSORT(A);
    int end = 0;
    int i = 0;

    REP(k,M){
        REP(j,BC[k][1]){
            if(i>=N){
                end=1;
                break;
            }
            if(A[i]<BC[k][0]){
                A[i]=BC[k][0];
                i++;
            }else{
                end=1;
                break;
            }
        }
        if(end==1)break;
    }

    ll sum=0;
    REP(u,N){
        sum += A[u];
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 6528
n=int(input())
l=list(map(int,input().split()))
ansL=[]
c=0
f=0
for j in range(n):
  for i in range(len(l)-1,-1,-1):
    if l[i]==i+1:
      ansL.append(l.pop(i))
      c+=1
      break
if c!=n:
  print(-1)
else:
  for k in range(len(ansL)-1,-1,-1):
    print(ansL[k])

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

#include <math.h>
#include <vector>

#include <algorithm>

#include <string>
#include <iostream>
using namespace std;

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

    int lim=0;
    int kaisuu=0;
    while (lim==0) {
        int hantei=0;
        int warukazu=(int)(pow(2,kaisuu+1));
        for (int i=0; i<N; i++) {
            if (A[i]%warukazu==0) {
            }
            else{hantei++;}
        }
        if (hantei==0) {
            kaisuu++;
        }
        else{lim++;}
        
    }
    cout<<kaisuu;
 
}


Measured memory_bytes: 892
use proconio::input;
use std::collections::BTreeSet;
fn main() {
    input! {
        s : String,
        x : i32,
        y : i32
    }
    let t: Vec<usize> = s.split('T').map(|itr| itr.len()).collect::<Vec<usize>>();
    let (px, py): (Vec<(usize, &usize)>, Vec<(usize, &usize)>) =
        t.iter().enumerate().partition(|(idx, _)| idx % 2 == 0);
    let (xs, ys): (Vec<usize>, Vec<usize>) = (
        px.iter().map(|(_, &v)| v).collect(),
        py.iter().map(|(_, &v)| v).collect(),
    );
    
    //println!("{:?}\n{:?}\n{:?}", t, xs, ys);
    let mut dp1: BTreeSet<i32> = BTreeSet::new();
    let mut dp2 = dp1.clone();
    dp1.insert(xs[0] as i32);
    dp2.insert(0);
    for &i in &xs[1..] {
        dp1 = dp1.into_iter().flat_map(|a| vec![a+i as i32,a-i as i32]).collect();
    }
    for i in ys {
        dp2 = dp2.into_iter().flat_map(|a| vec![a+i as i32,a-i as i32]).collect();
    }
    println!(
        "{}",
        if dp1.contains(&x) && dp2.contains(&y)
        {
            "Yes"
        } else {
            "No"
        }
    );
}


Measured memory_bytes: 2392
import sys
import os

N, L, *A = map(int, os.read(0, 10**8).split())

def main(L, A):
    N = len(A)
    is_long = [x + y >= L for x, y in zip(A, A[1:])]
    if not any(is_long):
        print('Impossible')
        return
    print('Possible')
    i = is_long.index(True)
    nums = list(range(1, i + 1)) + list(range(N - 1, i, -1))
    print(*nums, sep='\n')

main(L, A)


Measured memory_bytes: 19940
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
string a,b,c;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> a >> b >> c;
  if(a[sz(a)-1]==b[0] && b[sz(b)-1]==c[0]){
    cout << "YES";
  }else{
    cout << "NO";
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<map>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
typedef long long ll;
using namespace std;

ll const MAX = 100005;
ll a[MAX], ques_f[MAX], c[MAX], ques_b[MAX];
ll const MOD = 1000000007;
ll mod_p(ll x, ll y) {
	return (x + y) % MOD;
}
ll mod_m(ll x, ll y) {
	return x * y%MOD;
}
ll mod_pow(ll x, ll y) {
	if (y <= 0) {
		return 1;
	}
	ll t = mod_pow(x, y / 2);
	if(y%2==0){
		return (t*t)%MOD;
	}
	else {
		return t * t%MOD*x%MOD;
	}
}

int main() {
	ll que = 0;
	string s;
	cin >> s;
	ll n = s.size();
	REP(i, 0, MAX - 1) {
		a[i] = ques_f[i] = ques_b[i] = c[i] = 0;
	}
	REP(i, 1, n) {
		char ch = s[i - 1];
		a[i] = a[i - 1];
		ques_f[i] = ques_f[i - 1];
		if (ch == 'A') {
			a[i]++;
		}
		else if (ch == '?') {
			ques_f[i]++;
			que++;
		}
	}
	for (ll i = n; i >= 1; i--) {
		char ch = s[i - 1];
		c[i] = c[i + 1];
		ques_b[i] = ques_b[i + 1];
		if (ch == 'C') {
			c[i]++;
		}
		else if (ch == '?') {
			ques_b[i]++;
		}
	}
	ll ans = 0;
	REP(i, 1, n) {
		char ch = s[i - 1];
		ll gg = 0;
		if (ch == '?') {
			gg = mod_m(mod_m(a[i - 1], c[i + 1]), mod_pow(3, que-1));
			ll ff = mod_p(mod_m(a[i - 1], ques_b[i + 1]), mod_m(ques_f[i - 1], c[i + 1]));
			ff = mod_m(ff, mod_pow(3, que - 2));
			gg = mod_p(gg, ff);
			ll kk = mod_m(ques_f[i - 1], ques_b[i + 1]);
			kk = mod_m(kk, mod_pow(3, que - 3));
			gg = mod_p(gg, kk);
		}
		else if (ch == 'B') {
			gg = mod_m(mod_m(a[i - 1], c[i + 1]), mod_pow(3, que));
			ll ff = mod_p(mod_m(a[i - 1], ques_b[i + 1]), mod_m(ques_f[i - 1], c[i + 1]));
			ff = mod_m(ff, mod_pow(3, que - 1));
			gg = mod_p(gg, ff);
			ll kk = mod_m(ques_f[i - 1], ques_b[i + 1]);
			kk = mod_m(kk, mod_pow(3, que - 2));
			gg = mod_p(gg, kk);

		}
		ans = mod_p(ans, gg);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#include <string>
#include <stdio.h>
#include <cstdlib>

using namespace std;

int main() {
    int n, m;
    int a[10000] ;
    int sum = 0;
    cin >> n >> m;
    for (int i = 1; i <= m; i++){
        cin >> a[i];
        sum = sum + a[i];
    }
    if (sum > n){
        cout << "-1";
    }
    else{
        cout << (n - sum);
    }
}


Measured memory_bytes: 3684
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		String input = sc.next();
		final int q = sc.nextInt();
		
		for(int i = 0; i < q; i++){
			final String ops = sc.next();
			final int a = sc.nextInt();
			final int b = sc.nextInt();
			//System.out.println(input);
			
			if("replace".equals(ops)){
				final String rep = sc.next();
				input = input.substring(0, a) + rep + input.substring(b + 1);
			}else if("reverse".equals(ops)){
				StringBuilder sb = new StringBuilder(input.substring(a, b + 1));
				input = input.substring(0, a) + sb.reverse() + input.substring(b + 1);
			}else if("print".equals(ops)){
				System.out.println(input.substring(a, b + 1));
			}
		}
		
		
	}
}

Measured memory_bytes: 20680
#include <iostream>

using namespace std;

  int main(){
  char yohou[3];
  char jissai[3];
  for(int i=0;i<3;i++){
  	cin >> yohou[i];  
  }
  for(int i=0;i<3;i++){
  	cin >> jissai[i];  
  }
  int count=0;
  for(int i=0;i<3;i++){
  	if(yohou[i]==jissai[i]){
    	count++;	
  	}
  } 
	cout << count << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, -1, 0, 1 };

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

class Point {
public:
	int x, y;
	Point() {}
	Point(int x, int y) : x(x), y(y) {}
	bool operator<(const Point &a) const {
		if (y == a.y) return x < a.x;
		return y < a.y;
	}
};

signed main() {
	int H, W, N;
	cin >> W >> H >> N;

	set<Point> st;

	REP(y, 1, H) st.insert(Point(W + 1, y));

	rep(i, N) {
		int X, Y;
		cin >> X >> Y;
		st.insert(Point(X, Y));
	}

	int nowX = 1;
	int nowY = 1;
	int ret = W;
	while (true) {
		auto it = st.upper_bound(Point(nowX, nowY));
		ret = min(ret, it->x - 1);
		if (it->x == nowX + 1) break;
		nowX++;
		if (nowY < H && st.count(Point(nowX, nowY + 1)) == 0) {
			nowY++;
		}
	}
	cout << ret << endl;

    return 0;
}


Measured memory_bytes: 25216
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <utility>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <stack>
#define N 1010
#define p 1000000007

using namespace std;

int s, k;
long long f[N];

long long powMod(long long a, long long b)
{
    long long r = 1;
    for (;b>0;b>>=1)
    {
        if (b&1)
        {
            r = r*a%p;
        }
        a = a*a%p;
    }
    return r;
}

void repa()
{
    f[0] = 1;
    for (long long i=1;i<N;i++)
    {
        f[i] = f[i-1]*i%p;
    }
}

long long Comb(long long n, long long m)
{
    if (n<m)
    {
        return 0;
    }
    return f[n]*powMod(f[m]*f[n-m]%p,p-2)%p;
}

int main()
{
    scanf("%d%d",&s,&k);
    repa();
    long long sum = Comb(k,1);
    long long t = Comb(k-1,1);
    if (s>1)
    {
        sum *= powMod(t,s-1);
    }
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define MAX 100000003
using namespace std;
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define loopr(i,a,n) for(auto i=(n-1);i>=a;i--)
#define rev(i,a,n) for(auto i=(n-2);i>a;i--)
#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++)
typedef long long ll;
const int mod = 1000000007;



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, k, cnt;
	cin >> n >> k;

	vector<int> a(n);
	loop(i, 0, n) cin >> a[i];

	loop (i, 0, n - k) {
		if (a[i]  < a[i + k])
			cout << "Yes\n" ;

		else
			cout << "No\n";

	}



	return 0;
}


Measured memory_bytes: 3904
// Problem: D - Friends
// Contest: AtCoder - AtCoder Beginner Contest 177
// URL: https://atcoder.jp/contests/abc177/tasks/abc177_d
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Muallif: Azimjon Mehmonali o'g'li

//=========================================================

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")

//=========================================================
#ifdef DEBUG
#define xtp xtp1
#else
#define xtp(x)
#endif
//=========================================================

#include <bits/stdc++.h>

using namespace std;

#define int long long

typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

#define F first
#define S second
#define pb push_back
#define endl "\n"

#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SORT(a) sort(ALL(a))
#define rSORT(a) sort(rALL(a))
#define REV(a) reverse(ALL(a))
#define sqr(x) ((x) * (x))

#define TEZ                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);

const long double PI = 3.1415926535897;
const int mod = 1000000007LL;
const int INF = 1e18;

signed main() {
	TEZ;

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

	vector<vi> g(n + 1, vi());

	set<ii> el;
	int a, b;

	for (int i = 0; i < m; i++) {
		cin >> a >> b;

		if (a > b) swap(a, b);

		if (el.count({a, b}) == 0) {
			g[a].pb(b);
			g[b].pb(a);

			el.insert({a, b});
		}
	}

	vi v(n + 1, 0);

	function<int(int)> dfs = [&](int u) {
		if (v[u]) {
			return 0ll;
		}

		v[u] = 1;
		int jv = 1;
		for (int h : g[u]) {
			jv += dfs(h);
		}

		return jv;
	};

	int jv = -INF;

	for (int i = 1; i <= n; i++) {
		if (!v[i]) {
			jv = max(jv, dfs(i));
		}
	}

	cout << jv << endl;

	return 0;
}


Measured memory_bytes: 40568
import math


K=input()
K=int(K)
sum=0

for num_a in range(1,K+1):
	for num_b in range(1,K+1):
		num_d=math.gcd(num_a,num_b)
		for num_c in range(1,K+1):
			num_e=math.gcd(num_c,num_d)
			sum=sum+num_e
			
print(sum)

Measured memory_bytes: 9140
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

#define add push_back
#define inf 2147000000

#define rep(i,n) for(int i=0;i<n;i++)
#define deb(a) cout<<a<<endl
#define out(a) cout<<a<<endl;

using namespace std;

int main(void){
	string str;
	cin>>str;
	for(int i=str.size()-1;i>=0;i--){
		cout<<str[i];
	}
	cout<<endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const ll MAX_N = 1 << 17;

ll n, dat[2*MAX_N - 1];

void init(int n_) {
    n = 1;
    while(n < n_) n *= 2;
    for(int i = 0; i < 2*n-1; ++i) dat[i] = INT_MAX;
}

void update(int k, int a){
    k += n - 1;
    dat[k] = a;
    while(k > 0){
        k = (k-1)/2;
        dat[k] = min(dat[k*2+1],dat[k*2+2]);
    }
}

int query(int a, int b, int k, int l, int r){
    if(r <= a || b <= l) return INT_MAX;
    
    if(a <= l && r <= b) return dat[k];
    else {
        int vl = query(a,b,k*2+1,l,(l+r)/2);
        int vr = query(a,b,k*2+2,(l+r)/2,r);
        return min(vl,vr);
    }
}


int main(){
    int N,q;
    cin >> N >> q;
    init(N);
        
    rep(i,q){
        int x,y,z;
        cin >> x >> y >> z;
        if(x) pr(query(y,z+1,0,0,n));
        else update(y,z);
    }
}


Measured memory_bytes: 5196
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a;
    cin >> b;
    
    int d = b -a;
    int w = 0;
    for(int i=0; i < d; i++){
        w += i;
    }
    
    int h = w - a;
    cout << h << endl;
    
    
    return 0;
}

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;

long beki(long a, long b){
  int t = 1;
  REP(q, b) t= t *  a;
  return t;
}

int main(){
   long n,p;
   cin >> n >> p;
   long ans = 1;
   double m = 1.0 / n;
   long s = pow(p, m) + 2;
   if(n == 1){
       ans = p;
     }else{
   FOR(i, 2, s){
     long  bk = pow(i , n);
    if(p % bk == 0) ans = i;
         } 
}
     cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    private static void solve() {
        Scanner scanner = new Scanner(System.in);
        char[][] pattern = new char[8][];
        
        for (int i = 0; i < 8; i++) {
            pattern[i] = scanner.next().toCharArray();
        }

        System.out.println(90);
        for (int j = 0; j < 8; j++) {
            for (int i = 7; i >= 0; i--) {
                System.out.print(pattern[i][j]);
            }
            System.out.println();
        }

        System.out.println(180);
        for (int i = 7; i >= 0; i--) {
            for (int j = 7; j >= 0; j--) {
                System.out.print(pattern[i][j]);
            }
            System.out.println();
        }

        System.out.println(270);
        for (int j = 7; j >= 0; j--) {
            for (int i = 0; i < 8; i++) {
                System.out.print(pattern[i][j]);
            }
            System.out.println();
        }

    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

const int INF = 1e9;

struct edge {
	int to, cost;
	edge(int t, int c) : to(t), cost(c) {}
};

using graph = vector<vector<edge>>;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> C(N), R(N);
	for (int i = 0; i < N; i++) {
		cin >> C[i] >> R[i];
	}
	vector<vector<int>> g(N);
	for (int i = 0; i < K; i++) {
		int A, B;
		cin >> A >> B; A--, B--;
		g[A].push_back(B);
		g[B].push_back(A);
	}
	graph G(N);
	for (int s = 0; s < N; s++) {
		vector<int> d(N, -1);
		queue<int> q;
		d[s] = 0;
		q.push(s);
		while (!q.empty()) {
			int v = q.front(); q.pop();
			if (d[v] == R[s]) continue;
			for (int to : g[v]) if (d[to] == -1) {
				G[s].emplace_back(to, C[s]);
				d[to] = d[v] + 1;
				q.push(to);
			}
		}
	}
	vector<int> d(N, INF);
	priority_queue<pii, vector<pii>, greater<>> pq;
	d[0] = 0;
	pq.emplace(0, 0);
	while (!pq.empty()) {
		auto p = pq.top(); pq.pop();
		if (p.first > d[p.second]) continue;
		for (auto e : G[p.second]) if (d[e.to] > p.first + e.cost) {
			d[e.to] = p.first + e.cost;
			pq.emplace(p.first + e.cost, e.to);
		}
	}
	cout << d[N - 1] << endl;
	return 0;
}



Measured memory_bytes: 127780
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
  io;
  double d,t,s;
  double ans;
  cin>>d>>t>>s;
  ans=d/s;
  if(ans<=t)
  cout<<"Yes\n";
  else
  cout<<"No\n";
  return 0;
}


Measured memory_bytes: 3732
package main

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

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

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
  defer writer.Flush()

  var n int
  var s string
  scanf("%d\n", &n)
  scanf("%s\n", &s)
  bs := []byte(s)
  for i, b := range bs {
    bs[i] = byte((int(b-'A')+n)%26) + 'A'
  }

  printf("%s\n", string(bs))
}


Measured memory_bytes: 768
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <vector>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
 
using namespace std;
 
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
#define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
 
 
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   // freopen("./input.txt","r",stdin);
  //  freopen("./output.txt","w",stdout);
    long long int n;
    cin>>n;
    cout<<n*n*n;
}

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

using namespace std;

int main () {

  int n, ans = 1;
  cin >> n;
  vector<int> v;
  while (n--) {
    int x;
    cin >> x;
    v.push_back(x);
  }

  for (int i = 1; i < v.size(); i++) {
    bool is = true;
    for (int j = i - 1; j >= 0; j--) {
      if (!(v[j] <= v[i])) {
        is = false;
      }
    }
    if (is) {
      ans++;
    }
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256