akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef set<int>        si;
typedef set<ii>         sii;

#define all(x) x.begin(),x.end()
#define clr(x,v) memset(x,v,sizeof x)
#define sz(x) (int)x.size()
#define forn(i,a,b) for(int i=a;i<b;i++)
#define re return

template<typename T> T sgn (T x)      {re x<0? -1:(x>0? 1:0); }
template<typename T> T gcd (T a, T b) {re a ? gcd (b % a, a) : b; }
template<typename T> T abs (T x)      {re x < 0 ? -x : x; }
template<typename T> T sqr (T x)      {re x*x;}

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define ins insert
#define y second
#define x first
#define endl "\n"
#define MOD (int)1e9+7
#define N (int)2e5+123

int n;
set<string> v;
string s;
void solve(){
    cin >> n;
}
int main(){_
    int n;
    cin >> n;
    while(n--){
        cin >> s;
        v.ins(s);
    }
    cout << sz(v)<<endl;
}

Measured memory_bytes: 19224
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		
		boolean flag = false;
		
		if( (a+b) % 3 == 0) {
			flag = true;
		}else if(a % 3 == 0) {
			flag = true;
		}else if(b % 3 == 0) {
			flag = true;
		}
		
		if(flag) {
			System.out.println("Possible");
		}else {
			System.out.println("Impossible");
		}
		
	}

}


Measured memory_bytes: 23380
n = int(input())
res = []
arufa = []
for i in range(97, 123):
    arufa.append(chr(i))
while n:
    if n == 0:
        break
    n -= 1
    res.append(arufa[int(n % 26)])
    n //= 26
res.reverse()
ans = "".join(res)
print(ans)


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    string s;
    cin >> s;
    if(s=="Sunny"){
        cout << "Cloudy" << endl;
    }else if(s=="Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
}

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

vector<long long> a,b,c;
vector<vector<long long> > happy;

long long dp(int day, int prev) {
    if (day < 0) {
        return 0;
    }
    if (prev >= 0 && happy[day][prev] != 0) {
        return happy[day][prev];
    }
    if (prev == 0) {
        happy[day][prev] = max(dp(day - 1, 1) + b[day],
                         dp(day - 1, 2) + c[day]);
    } else if (prev == 1) {
        happy[day][prev] = max(dp(day - 1, 0) + a[day],
                         dp(day - 1, 2) + c[day]);
    } else if (prev == 2) {
        happy[day][prev] = max(dp(day - 1, 0) + a[day],
                         dp(day - 1, 1) + b[day]);
    } else {
        return max({dp(day - 1, 0) + a[day],
                    dp(day - 1, 1) + b[day],
                    dp(day - 1, 2) + c[day]});
    }
    // cout << day << " day : " << happy[day][prev] << endl;
    return happy[day][prev];
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x,y,z;
        cin >> x >> y >> z;
        a.push_back(x);
        b.push_back(y);
        c.push_back(z);
        vector<long long> m;
        m.push_back(0);
        m.push_back(0);
        m.push_back(0);
        happy.push_back(m);
    }
    cout << dp(n-1, -1) << endl;
}


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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define endl "\n"
#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007
//グリッドグラフの範囲チェック
bool range_validation(int y,int x,int h,int w){
    return y>=0 && y<h && x>=0 && x < w;
}
//ビットカウント
int popcount(long bits){
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int h,w;
  cin >> h >> w;

  vector<string> a(h);

  REP(i,h)cin >> a[i];

  vector<vector<ll>> dp(h,vector<ll>(w,0));

  dp[0][0] = 1;

  REP(i,h){
    REP(j,w){
      if(j+1 < w && a[i][j+1] == '.'){
        dp[i][j+1] += dp[i][j];
        if(dp[i][j+1] >= MOD){
          dp[i][j+1] -= MOD;
        }
      }

      if(i+1 < h && a[i+1][j] == '.'){
        dp[i+1][j] += dp[i][j];
        if(dp[i+1][j] >= MOD){
          dp[i+1][j] -=MOD;
        }
      }
    }
  }
  cout << dp[h-1][w-1] << endl;
  return 0;
}


Measured memory_bytes: 12156
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tokenizer = new StringTokenizer(input.readLine());
        int a = Integer.parseInt(tokenizer.nextToken());
        int b = Integer.parseInt(tokenizer.nextToken());
        System.out.println(a > b ? a-1 : a);
    }
}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

bool check(int a, int b, int c) {
    if(a % 2 == 0 && b % 2 == 0 && c % 2 == 0) return true;
    else return false;
}

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(!check(a, b, c)) {
        cout << 0 << endl;
        return 0;
    }
    if(a == b && b == c && a == c) {
        cout << -1 << endl;
        return 0;
    }
    int ans = 0;
    while(check(a, b, c)) {
        int x, y, z;
        x = a / 2;
        y = b / 2;
        z = c / 2;
        a = y + z;
        b = x + z;
        c = x + y;
        ans++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
h,w=map(int,input().split())
cost=[]
for i in range(10):
    cost.append(list(map(int,input().split())))

for i in range(10):
    for j in range(10):
        for k in range(10):
            if cost[j][k]>cost[j][i]+cost[i][k]:
                cost[j][k]=cost[j][i]+cost[i][k]
ans=0
for i in range(h):
    for j in map(int,input().split()):
        if j!=-1:
            ans+=cost[j][1]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;cin>>n;
  int x;cin>>x;
  int b,c=1000;
  for(int i=0;i<n;i++){
    cin>>b;
    x -= b;
    c = min(c,b);
  }
  cout << n + x/c << endl;
  return 0;
}

Measured memory_bytes: 256
function del( row, num ) {
   row.splice( row.indexOf(num), 1 );
}

let S = [1,2,3,4,5,6,7,8,9,10,11,12,13];
let H = [1,2,3,4,5,6,7,8,9,10,11,12,13];
let C = [1,2,3,4,5,6,7,8,9,10,11,12,13];
let D = [1,2,3,4,5,6,7,8,9,10,11,12,13];

let input = require('fs').readFileSync('/dev/stdin', 'utf8').split("\n");
for( let i = 1; i < input.length; i++ ) {
  let sp = input[i].split(" ");
  sp[1] = Number(sp[1]);
  if( sp[0] === "S" ) {
    del( S, sp[1] );
  } else if ( sp[0] === "H" ) {
    del( H, sp[1] );
  } else if ( sp[0] === "C" ) {
    del( C, sp[1] );
  } else if ( sp[0] === "D" ) {
    del( D, sp[1] );
  }
}

for( let i = 0; i < S.length; i++ ) console.log( "S " + S[i] );
for( let i = 0; i < H.length; i++ ) console.log( "H " + H[i] );
for( let i = 0; i < C.length; i++ ) console.log( "C " + C[i] );
for( let i = 0; i < D.length; i++ ) console.log( "D " + D[i] );



Measured memory_bytes: 15144
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define re register
#define pb push_back
#define fi first
#define se second
const int N=1e6+10;
const int M=1e6;
const int mod7=1e9+7;
const int mod=1e9+7;
void read(int &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
void read(ll &a)
{
    a=0;int d=1;char ch;
    while(ch=getchar(),ch>'9'||ch<'0')
        if(ch=='-')
            d=-1;
    a=ch^48;
    while(ch=getchar(),ch>='0'&&ch<='9')
        a=(a<<3)+(a<<1)+(ch^48);
    a*=d;
}
ll f1[N],f2[N],f3[N];
int a[N];
int main()
{
    int n;read(n);
    for(re int i=1;i<=n;i++) read(a[i]);
    if(n%2==0)
    {
        f1[1]=a[1];
        f1[2]=a[2];
        for(re int i=3;i<=n;i++)
        {
            if(i&1) f1[i]=f1[i-2]+a[i];
            else f1[i]=max(f1[i-3],f1[i-2])+a[i];
        }
        printf("%lld\n",max(f1[n-1],f1[n]));
    }
    else
    {
        f1[1]=a[1];f2[1]=a[2];f3[1]=a[3];
        for(re int i=2;i<=n/2;i++)
        {
            f1[i]=f1[i-1]+a[(i<<1)-1];
            f2[i]=max(f1[i-1],f2[i-1])+a[(i<<1)];
            f3[i]=max(f1[i-1],max(f2[i-1],f3[i-1]))+a[(i<<1)+1];
        }
        printf("%lld\n",max(f1[n/2],max(f2[n/2],f3[n/2])));
    }
    return 0;
}

Measured memory_bytes: 6796
#include <iostream>
#include <algorithm>
#define rng(x1, y1, x2, y2) (sum[y2][x2] + sum[y1][x1] - sum[y2][x1] - sum[y1][x2])
using namespace std;
int H, W, ra, o, a[40][40], sum[40][40], dp[40][40][40][40];
inline int solve(int x1, int y1, int x2, int y2) {
	if (dp[y1][x1][y2][x2]) return dp[y1][x1][y2][x2];
	int ret = 1048576 + rng(x1, y1, x2, y2);
	for (int i = x1 + 1; i < x2; i++) {
		int petl = rng(x1, y1, i, y2), petr = rng(i, y1, x2, y2);
		if (min(petl, petr) >= o) {
			int resl = solve(x1, y1, i, y2);
			int resr = solve(i, y1, x2, y2);
			int res = ((resl + resr) >> 20 << 20) + min(resl & 1048575, resr & 1048575);
			ret = max(ret, res);
		}
	}
	for (int i = y1 + 1; i < y2; i++) {
		int petl = rng(x1, y1, x2, i), petr = rng(x1, i, x2, y2);
		if (min(petl, petr) >= o) {
			int resl = solve(x1, y1, x2, i);
			int resr = solve(x1, i, x2, y2);
			int res = ((resl + resr) >> 20 << 20) + min(resl & 1048575, resr & 1048575);
			ret = max(ret, res);
		}
	}
	return dp[y1][x1][y2][x2] = ret;
}
int main() {
	while (scanf("%d%d%d", &H, &W, &ra), H) {
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) scanf("%d", &a[i][j]);
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) sum[i + 1][j + 1] = sum[i + 1][j] + sum[i][j + 1] - sum[i][j] + a[i][j];
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				for (int k = i + 1; k <= H; k++) {
					for (int l = j + 1; l <= W; l++) dp[i][j][k][l] = 0;
				}
			}
		}
		o = sum[H][W] - ra;
		int ret = solve(0, 0, W, H);
		printf("%d %d\n", (ret >> 20), ((ret - o) & 1048575));
	}
}

Measured memory_bytes: 9124
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main(){
    int n;
    double memo = 0,ave = 0;
    int a[1001];
    
    while(1){
        cin >> n;
        if(n){
          	memo = 0;
          	ave = 0;
            rep(i,0,n){
                cin >> a[i];
                memo += a[i];
            }
            
            ave =  memo / n;
          
          	memo = 0;
            
            rep(i,0,n){
                memo += (double)pow((a[i]-ave),2);
            }
            
            memo /= n;
            
            cout << setprecision(10) << (double)sqrt(memo)<< endl;
        }
        else{
            break;
        }
    }
  	
    return 0;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    // Are there any ns which satisfy a*n % b = c
    for (int n = 1; n <= b; n++) {
        if (a*n % b == c) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}


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

# from numba import njit
import sys
sys.setrecursionlimit(10**8)
# input = stdin.readline

# @njit
def solve(n,k,r,s,p,t):
  winHand = {"r":"p", "s":"b", "p":"s"}
  bestHandMemo = [""]*(n+1) # i手目の勝ち手
  
  memo = [-1]*(n+1)
  def calcPoint(char):
    if char == "r":
      return p
    elif char == "s":
      return r
    elif char == "p":
      return s
    else:
      raise ValueError
  def dp(i):
    if i == 0:
      return 0
    elif memo[i] != -1:
      return memo[i]
    elif i <= k:
      bestHandMemo[i-1] = winHand[t[i-1]] # 自由に出せる
      return dp(i-1) + calcPoint(t[i-1])
    elif winHand[t[i-1]] == bestHandMemo[i-k-1]:
      bestHandMemo[i-1] = "" # あいこでも負けても同じこと
      return dp(i-1)
    else: # 勝てる
      bestHandMemo[i-1] = winHand[t[i-1]]
      return dp(i-1) + calcPoint(t[i-1])
  
  for i in range(n+1):
    memo[i] = dp(i)

  return memo[n]
    



def main():
  N,K = map(int,input().split())
  R,S,P = map(int,input().split())
  T = input()
  print(solve(N,K,R,S,P,T))
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 13764
#include<stdio.h>
 
#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2
 
int n,M[MAX][MAX];
 
void dijkstra(){
  int i,j,u,v,min;
  int d[MAX],color[MAX];
  
  for(i=0;i<n;i++){ 
    d[i]=INFTY;
    color[i]=WHITE;
  }
  
  d[0]=0;
color[0]=GRAY;
 
  while(1){
    min=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(min>d[i] && color[i]!=BLACK){
    u=i;
    min=d[i];
      }
    }
    if(u==-1){
      break;
    }
    color[u]=BLACK;
    for(v=0;v<n;v++){ 
      if(M[u][v]!=INFTY && color[v]!=BLACK){
    if(d[v]>d[u]+M[u][v]){
      d[v]=d[u]+M[u][v];
      color[v]=GRAY;
    }
      }
    }
  }
  for(i=0;i<n;i++){ 
    printf("%d %d\n",i,(d[i]==INFTY?-1:d[i]));
  }
}
  
int main(){
  int i,j,k,c,u,v;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){ 
    for(j=0;j<n;j++){
      M[i][j]=INFTY;
    }
  }
 
  for(i=0;i<n;i++){ 
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d %d",&v,&c);
      M[u][v]=c;
    }
  }
  dijkstra(); 
 
  return 0;
}

Measured memory_bytes: 636
#include<stdio.h>
int main(){
  int a[3],b,c=0,d=0;
  for(int i=0; i<3; i++){
    scanf("%d",&a[i]);
    if(c<a[i]){c=a[i];}
    d+=a[i];
  }
  scanf("%d",&b);
  for(int i=0; i<b; i++){
    d+=c;c*=2;
  }
  printf("%d",d);
  return 0;}

Measured memory_bytes: 128
S=input()
T=input()


if len(S)+1==len(T):
    for i in range(len(S)): #回数の時は絶対range()
        if S[i]==T[i]:
            a='ok'
            continue
        else:
            a='no'
            break
else:
    print('no')

if a=='ok':
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9048
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;

using ll = long long;
ll mod = pow(10, 9) + 7;

template <typename T> void output(T, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);
Bint comb(Bint, Bint);
void prime_map(map<ll, ll> &, ll);

int main() {
    // source
    string s;
    cin >> s;
    int count[27] = {};
    rep(i, s.length()) { count[s[i] - 'a']++; }

    rep(i, 27) {
        if (count[i] == 0) {
            if (i == 26) {
                cout << "None" << endl;
            } else {
                cout << (char)(i + 'a') << endl;
            }
            break;
        }
    }
    return 0;
}

Bint comb(Bint a, Bint b) {
    Bint ans = 1;

    if (a < b) {
        return 0;
    }

    rep(i, b) {
        ans *= a - i;
        ans /= i + 1;
    }

    return ans;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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

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

void prime_map(map<ll, ll> &m, ll num) {

    if (num == 1) {
        return;
    }
    ll cache = num;
    repd(i, 2, sqrt(num) + 2) {
        if (num % i == 0) {
            if (m[i] == 0) {
                m[i] = 1;
            } else {
                m[i]++;
            }

            num /= i;
            break;
        }
    }
    if (cache == num) {
        if (m[num] == 0) {
            m[num] = 1;
        } else {
            m[num]++;
        }

        return;
    }
    prime_map(m, num);
    return;
}


Measured memory_bytes: 512
import java.util.Queue;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();  // プロセス数
		int Q = sc.nextInt();  // クオンタム
		Map<String, Integer> hmap = new HashMap<String, Integer>();
		Queue<String> queue = new ArrayDeque<String>();  // 主役
		List<String> terminated = new ArrayList<String>();  // プロセスの名前を終わった順に格納する
		int timestamp = 0;

		for(int i = 0; i < N; i++) {
			String name = sc.next();
			int time = sc.nextInt();
			hmap.put(name, time);
			queue.add(name);
		}

		while(!queue.isEmpty()) {
			String p = queue.peek();
			if(hmap.get(p) <= Q) {  // クオンタム以内にプロセスpが終了する場合
				timestamp += hmap.get(p);
				terminated.add(queue.poll());
				hmap.put(p, timestamp);   // プロセスpが終了した時刻を記録
			}else {                 // クオンタム以内にプロセスpが終わらない場合
				timestamp += Q;
				queue.add(queue.poll());  // プロセスを待ち行列の最後尾へ
				hmap.put(p, hmap.get(p) - Q);
			}
		}

		for(String p : terminated) {
			System.out.println(p + " " + hmap.get(p));
		}

		sc.close();
	}
}


Measured memory_bytes: 78192
#include<bits/stdc++.h>
using namespace std;
void solve()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int s=0;
    for(int i=0;i<k;i++)
    {
        s+=a[i];
    }
    cout<<s<<endl;
}
int main()
{
    solve();
}

Measured memory_bytes: 3592
A = input()
for i in range(2**3):
    s = A
    for j in range(3):
        if i>>j & 1:
            s = s[:j-3]+"+"+s[j-3:]
        else:
            s = s[:j-3]+"-"+s[j-3:]
    ans = int(s[0])
    for k in range(len(s)):
        if k%2 == 0:
            n = int(s[k])
        if s[k-1] == "+":
            ans += n
        elif s[k-1] == "-":
            ans -= n
    if ans == 7:
        print(s+"=7")
        break


Measured memory_bytes: 3064
#include <stdio.h>

int board[8][8];
int rows[8], cols[8];
int positive[15], negative[15];

void print()
{
  int i,j;

  for (i = 0; i < 8; i++) {
    for (j = 0; j < 8; j++) {
      if (board[i][j] && rows[i] != j)
        return;
    }
  }

  for (i = 0; i < 8; i++) {
    for (j = 0; j < 8; j++) {
      if (rows[i] == j)
        printf("Q");
      else
        printf(".");
    }
    printf("\n");
  }
}

void solve(int cur) {
  int i;

  if (cur == 8) {
    print();
    return;
  }

  for (i = 0; i < 8; i++) {
    if (!cols[i] && !positive[cur + i] && !negative[cur - i + 7]) {
      rows[cur] = i;
      cols[i] = 1;
      positive[cur + i] = 1;
      negative[cur - i + 7] = 1;

      solve(cur + 1);

      rows[cur] = 0;
      cols[i] = 0;
      positive[cur + i] = 0;
      negative[cur - i + 7] = 0;
    }
  }
}

int main() {
  int k, i, j, r, c;

  memset(board, 0, sizeof(board));
  memset(rows, 0, sizeof(rows));
  memset(cols, 0, sizeof(cols));
  memset(positive, 0, sizeof(positive));
  memset(negative, 0, sizeof(negative));


  scanf("%d", &k);

  for (i = 0; i < k; i++) {
    scanf("%d %d", &r, &c);
    board[r][c] = 1;
  }

  solve(0);

  /* attempt 1
   for (i = 2; i < 10; i++) {
    for (j = 2; j < 10; j++) {
      if ((rows[i-2] || cols[j-2]) && board[i][j] != 1)
        board[i][j] = 2;
      else if (board[i+1][j+1] == 1 || board[i-1][j+1] == 1 || board[i+1][j-1] == 1 || board[i-1][j-1] == 1)
        board[i][j] = 2;
    }
  }
  */
}




Measured memory_bytes: 2100
#include <cstdio>
#include <vector>
#include <algorithm>

int main() {
  int N, D, X;
  scanf("%d %d %d", &N, &D, &X);

  for (int i=0; i<N; ++i) {
    int A;
    scanf("%d", &A);
    for (int j=1; j<=D; j+=A)
      ++X;
  }

  printf("%d\n", X);
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b= sc.nextInt();
        int c = sc.nextInt();
		
        int t = 0;
        if(a > b) {
            t = a;
            a = b;
            b = t;
        }
        if(b > c) {
            t = b;
            b = c;
            c = t;
        }
        if(a > b) {
            t = a;
            a = b;
            b = t;
        }
        
        System.out.println(a+" "+b+" "+c);
		sc.close();

	}
}


Measured memory_bytes: 26388
#include <iostream>

int main()
{
	int n, m, l;
	std::cin >> n >> m >> l;
	int a[n][m], b[m][l];
        long c[n][l] {};
	for (int i=0; i!=n; ++i)
		for (int j=0; j!=m; ++j)
			std::cin >> a[i][j];
	for (int i=0; i!=m; ++i)
		for (int j=0; j!=l; ++j)
			std::cin >> b[i][j];
	for (int i=0; i!=n; ++i) {
		for (int j=0; j!=l; ++j) {
			for (int k=0; k!=m; ++k)
				c[i][j] += a[i][k] * b[k][j];
			std::cout << c[i][j];
			if (j != l-1) std::cout << ' ';
		}
		std::cout << '\n';
	}
}

Measured memory_bytes: 3248
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;


int main(){
  int n;
  cin >> n; 
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = a[n - 1] - a[0];
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <fstream>

using namespace std;

int main()
{
    int n;
    cin >> n ;
    int A[n];
    for (int i=0;i<n;i++)
        cin >> A[i];
    sort(A,A+n);
    int Max=0;
    int up,low;
    for (int i=0;i<n;i++){
        up = std::upper_bound(A,A+n,A[i]+1)-A;
        low = std::lower_bound(A,A+n,A[i]-1)-A;
        Max=max(up-low,Max);
    }
    cout << Max;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(){
  long long i,j,n,max=-1000000,min=1000000,sum=0;
  scanf("%lld",&i);
  for(j=0;j<i;j++){scanf("%lld",&n);
    if(n>max){max=n;
    }
    if(n<min){min=n;
    }
    sum=sum+n;
  }
  printf("%lld %lld %lld\n",min,max,sum);
  
  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<algorithm>
int N_MAX=500;
using namespace std;
int main()
{
  int n,m,q,l,r,i,j,k;
  int a[N_MAX][N_MAX];
  cin >> n >> m >> q;
  for(i=0;i<n;i++)
    fill(a[i],a[i]+n,0);
  for(k=0;k<m;k++){
    cin >> l >> r;
    a[l-1][r-1]++;
  }
  for(k=1;k<n;k++)
    for(i=0;i<n-k;i++){
      j=i+k;
      a[i][j]+=a[i][j-1]+a[i+1][j]-a[i+1][j-1];
    }
  for(k=0;k<q;k++){
    cin >> l >> r;
    cout << a[l-1][r-1] << endl;
  }
  return 0;
}

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

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

  int ans = 0;
  rep(i, n) {
    int x;
    cin >> x;
    ans += 2 * min(x, k - x);
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var n = Console.ReadLine().ToInt();
		var p = Input();
		var a = new long[n];
		long s = -1;
		
		for(int i = 0; i < n; i++)
		{
			a[i] = p[i].ToLong();
			s = Math.Max(a[i], s);
		}
		long t = -1;
		for(int i = 0; i < n; i++)
		{
			if(a[i] == s)
				continue;
			if(Math.Abs(a[i] - s/2) < Math.Abs(t - s/2))
			{
				t = a[i];
			}
		}
		Console.WriteLine("{0} {1}", s, t);
	}

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static long Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 20192
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int sumTime = 0;
    int[] time = new int[N];
    for(int i = 0; i < N; i++) {
      time[i] = sc.nextInt(); 
      sumTime += time[i];
    }
    int M = sc.nextInt();
    for(int i = 0; i < M; i++) {
      int P = sc.nextInt() - 1;
      int ans = sumTime - time[P] + sc.nextInt();
      System.out.println(ans);
    }
  }
}

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

int main() {
    int a,b;
    char op;
    while (true) {
        cin >> a >> op >> b;
        if (op =='+') cout << a+b << endl; 
        else if (op == '-') cout << a-b << endl;
        else if (op == '*') cout << a*b << endl;
        else if (op == '/') cout << a/b << endl;
        else break;
    }
}


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

int main(){
  
	string X, Y;
  	cin >> X >> Y;
  	
  	int x,y;
  
  	if( X == "A" )x = 10;
    else if( X == "B" )x = 11;
    else if( X == "C" )x = 12;
	else if( X == "D" )x = 13;
    else if( X == "E" )x = 14;
	else if( X == "F" )x = 15;
  
  	if( Y == "A" )y = 10;
    else if( Y == "B" )y = 11;
    else if( Y == "C" )y = 12;
	else if( Y == "D" )y = 13;
    else if( Y == "E" )y = 14;
	else if( Y == "F" )y = 15;
      
  	if( x > y )cout << ">" << endl;
    else if( x == y )cout << "=" << endl;
    else if( x < y )cout << "<" << endl;
  
}

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

using namespace std;

const int N = 1e5 + 1;
const int MOD = 1e9 + 7;
int m[N + 1], lp[N + 1];

int mob(int x) {
    int cnt = 0;
    while (x > 1) {
        int deg = 0, d = lp[x];
        while (x % d == 0) {
            x /= d;
            deg++;
            if (deg > 1)
                return 0;
        }
        cnt++;
    }
    if (cnt & 1) return -1;
    else return 1;
}

void precalc() {
    for (int i = 2; i <= N; ++i)
        if (!lp[i]) for (int j = i; j <= N; j += i)
            if (!lp[j]) lp[j] = i;

    m[1] = 1;
    for (int i = 2; i <= N; ++i) {
        m[i] = mob(i);
        if (m[i] < 0)
            m[i] += MOD;
    }
}

int binpow(int a, int n) {
    int res = 1;
    while (n) {
        if (n & 1)
            res = (1LL * res * a) % MOD;
        a = (1LL * a * a) % MOD;
        n >>= 1;
    }
    return res;
}

void solve() {
    precalc();
    int n, K; cin >> K >> n;
    int ans = 0;
    for (int k = 1; k <= n; k++) {
        for (int d = 1; d <= n / k; d++) {
            int res = (1LL * k * m[d]) % MOD;
            res = (1LL * res * binpow(n / (k * d), K)) % MOD;
            ans += res;
            if (ans > MOD)
                ans -= MOD;
        }
    }
    cout << ans;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


Measured memory_bytes: 4432
import java.util.*;

public class Main {
  public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int a = sc.nextInt();
    	if(a < 1200) {
          System.out.println("ABC");
        } else {
          System.out.println("ARC");
        }
  }
}

Measured memory_bytes: 23892
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut stack: Vec<String> = vec![];
    let mut done: bool = false;
    while !done {
        let operation: String = read();
        if operation == "" {
            done = true;
        } else {
            match &*operation {
                "+" => {
                    let number_1: String = stack.pop().unwrap();
                    let number_2: String = stack.pop().unwrap();
                    let number_1_int: i64 = number_1.parse().unwrap();
                    let number_2_int: i64 = number_2.parse().unwrap();
                    let number: i64 = number_2_int + number_1_int;
                    stack.push(number.to_string());
                }
                "-" => {
                    let number_1: String = stack.pop().unwrap();
                    let number_2: String = stack.pop().unwrap();
                    let number_1_int: i64 = number_1.parse().unwrap();
                    let number_2_int: i64 = number_2.parse().unwrap();
                    let number: i64 = number_2_int - number_1_int;
                    stack.push(number.to_string());
                }
                "*" => {
                    let number_1: String = stack.pop().unwrap();
                    let number_2: String = stack.pop().unwrap();
                    let number_1_int: i64 = number_1.parse().unwrap();
                    let number_2_int: i64 = number_2.parse().unwrap();
                    let number: i64 = number_2_int * number_1_int;

                    stack.push(number.to_string());
                }
                _ => stack.push(operation),
            }
        }
    }
    println!("{}", stack[0]);
}



Measured memory_bytes: 5036
module Main where

import Data.Functor
import Data.List

main :: IO ()
main = do
  { [ss] <- getInts
  ; let (mm,s) = ss `divMod` 60
  ; let (h,m)  = mm `divMod` 60
  ; putStrLn (intercalate ":" (map show [h,m,s]))
  }

getInts :: IO [Int]
getInts = do
  { line <- getLine
  ; let ints = map readInt (words line)
  ;  return ints
  }

getInts' :: IO [Int]
getInts' = do
  { line <- getLine
  ;  return (map readInt (words line))
  }

getInts'' :: IO [Int]
getInts'' = map readInt . words <$> getLine


readInt :: String -> Int
readInt = read                                                                                                                                                                                                               

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define All(v) (v).begin(), (v).end()
#define Pb push_back

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

    ll n,l[201],ans=0;
    cin >> n;
    rep(i,2*n) cin >> l[i];
    sort(l,l+2*n,greater<int>());
    for(ll i=1;i<2*n;i+=2) ans += l[i];
    cout << ans << "\n";
    return 0;
}

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

int main(){
    int n,x,y;
    int i,j,min;
    cin>>n>>x>>y;
    int count[n] = {0};
    for(i=1;i<=n;i++){
        for(j=i+1;j<=n;j++){
            min = (std::min)({j-i,abs(x-i)+1+abs(y-j),abs(y-i)+1+abs(x-j)});
            count[min]++;
        }
    }
    for(i=1;i<n;i++){
        cout<<count[i]<<endl;
    }
}

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

int main()
{
	int a, b, c;

	cin >> a >> b >> c;

	if(a*b<c){
		cout << a * b << endl;
	}

	else {
		cout << c << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=16;
const int MOD=1e9+7;
int n,m;
int a[N+1];
long long f[N+1][1<<N|1],fac[1<<N|1],inv[1<<N|1];
long long ksm(long long a,long long b)
{
	long long res=1;
	while(b)
	{
		if(b&1) res=res*a%MOD;
		a=a*a%MOD,b>>=1;
	}
	return res;
}
long long C(int n,int m)
{
    if(n<m) return 0;
    return fac[n]*inv[m]%MOD*inv[n-m]%MOD;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
		scanf("%d",&a[i]);
    fac[0]=1;
    for(int i=1;i<=(1<<n);i++)
		fac[i]=fac[i-1]*i%MOD;
	inv[1<<n]=ksm(fac[1<<n],MOD-2);
    for(int i=1<<n;i>=1;i--)
    	inv[i-1]=inv[i]*i%MOD;
    sort(a+1,a+m+1,greater<int>());
    f[0][0]=1;
    for(int i=1;i<=m;i++)
        for(int j=0;j<(1<<n);j++)
		{
            f[i][j]=(f[i][j]+f[i-1][j])%MOD;
            for(int k=0;k<n;k++)
			{
                if(j&(1<<k)) continue;
                if((1<<n)-j-a[i]<(1<<k)-1) break;
                f[i][j|(1<<k)]=(f[i][j|(1<<k)]-f[i-1][j]*C((1<<n)-j-a[i],(1<<k)-1)%MOD*fac[1<<k]%MOD+MOD)%MOD;
            }
        }
    long long ans=0;
    for(int i=0;i<(1<<n);i++)
        ans=(f[m][i]*fac[(1<<n)-i-1]%MOD+ans)%MOD;
    ans=(ans*(1<<n)%MOD)%MOD;
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 9472
n,a,b=map(int,input().split())
m=10**9+7
def cmb(x,y):
    c=1
    for i in range(1,y+1):
      c=(c*(x-i+1)*pow(i,m-2,m))%m
    return c
print((pow(2,n,m)-1-cmb(n,a)-cmb(n,b))%m)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

Int M;
string C;

Int calc(Int from, Int to){
  static Int mem[10][10], used[10][10];
  if(used[from][to]++) return mem[from][to];
  Int N = C.size();
  Int B = 1;

  Int res = 0;
  for(Int i=0;i<N;i++){
    if(C[N - 1 - i] == from + '0') res = (res + to * B)% mod;
    B  = B * 10 % mod;
  }

  return mem[from][to] = res;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin>>M;
  cin>>C;
  Int N = C.size();

  vector<Int> to(10); iota(to.begin(), to.end(), 0);
  do{
    Int m = 0;
    for(Int i=0;i<10;i++){
      m += calc(i, to[i]);
      m %= mod;
    }
    if(C.size() != 1 && to[C[0] - '0'] == 0) m = -1;

    if(m == M){
      string ans(N, '?');
      for(Int i=0;i<N;i++) ans[i] = char('0'+to[C[i] - '0']);
      cout<<ans<<endl;
      return 0;
    }
  }while(next_permutation(to.begin(), to.end()));

  cout<<-1<<endl;
  return 0;
}



Measured memory_bytes: 3300
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define fill( x, y ) memset( x, y, sizeof x )
#define copy( x, y ) memcpy( x, y, sizeof x )
using namespace std;

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

inline int read()
{
	int sc = 0, f = 1; char ch = getchar();
	while( ch < '0' || ch > '9' ) { if( ch == '-' ) f = -1; ch = getchar(); }
	while( ch >= '0' && ch <= '9' ) sc = sc * 10 + ch - '0', ch = getchar();
	return sc * f;
}

const int MAXN = 200005;
const int mod = 1e9 + 7;

struct node { int x, v; bool operator < ( const node &b ) const { return x < b.x; } } a[MAXN];
int l[MAXN], r[MAXN], f[MAXN], n, v[MAXN], ans;
pa t[MAXN];

inline void inc(int &x, int y) { x += y; if( x >= mod ) x -= mod; }
inline void dec(int &x, int y) { x -= y; if( x < 0 ) x += mod; }

int main()
{
#ifdef wxh010910
	freopen( "data.in", "r", stdin );
#endif
	n = read();
	for( int i = 1 ; i <= n ; i++ ) a[ i ].x = read(), a[ i ].v = v[ i ] = read();
	sort( a + 1, a + n + 1 ); sort( v + 1, v + n + 1 );
	for( int i = 1 ; i <= n ; i++ ) r[ i ] = max( a[ i ].v, r[ i - 1 ] );
	for( int i = n ; i ; i-- ) l[ i ] = i == n ? a[ i ].v : min( a[ i ].v, l[ i + 1 ] );
	for( int i = 1 ; i <= n ; i++ ) t[ i ] = mp( lower_bound( v + 1, v + n + 1, l[ i ] ) - v, lower_bound( v + 1, v + n + 1, r[ i ] ) - v );
	sort( t + 1, t + n + 1 );
	f[ 1 ] = 1; if( t[ 1 ].yy == n ) ans = 1;
	for( int i = 2, j = 0 ; i <= n ; i++ )
	{
		while( t[ j + 1 ].yy < t[ i ].xx - 1 ) j++;
		f[ i ] = f[ i - 1 ]; dec( f[ i ], f[ j ] );
		if( t[ i ].xx == 1 ) inc( f[ i ], 1 );
		if( t[ i ].yy == n ) inc( ans, f[ i ] );
		inc( f[ i ], f[ i - 1 ] );
	}
	return printf( "%d\n", ans ), 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a[i];
    int ans=0;
    for(int i=0; i<n; i++){
        if(a[i]<a[i+1]){
            while(i+1<n&&a[i]<=a[i+1]){
                i++;
            }
        }else if(a[i]>a[i+1]){
            while(i+1<n&&a[i]>=a[i+1]){
                i++;
            }
        }else{
            while(i+1<n&&a[i]==a[i+1]){
                i++;
            }
            i--;
            continue;
        }
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    while(cin >> n and n) {
        int m;
        cin >> m;
        string s;
        cin >> s;
        vector<int> lens = {0};
        char expected = 'I';
        for(int i = 0; i < s.size(); i++) {
            if(s[i] == expected) {
                lens.back()++;
                expected = expected == 'I' ? 'O' : 'I';
            } else {
                lens.push_back(0);
                expected = 'I';
                if(s[i] == expected) {
                    lens.back()++;
                    expected = expected == 'I' ? 'O' : 'I';
                }
            }
        }
        int ans = 0;
        for(int len : lens) {
            ans += max(0, (len - 1) / 2 - n + 1);
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 4516
#include<iostream>
#include<vector>
#include<string>
#include<utility>
#include<algorithm>
using namespace std;

bool hikaku(const pair<int,string>& A,const pair<int,string>& B){
	return A.first > B.first;
}
int main(){
	int n,k,win,lose,les;
	string s;
	
	while(cin >> n,n){
		vector<pair<int,string> >p; // vector < pair <string, int> >p;
	
		for(int i=0;i<n;i++){
			cin >> s ;// cin >> s;
			les = 0;
			for(int j=0;j<n-1;j++){
				cin >> k;
				if(k==0)
				les+=10;//les++;
				if(k==2)//if(k==1)
				les+=1;
			}
			p.push_back( make_pair(les,s) );
		}
		stable_sort(p.begin(),p.end(),hikaku );
		//stable_sprt(p.begin(),p.end(),greater<pair<string , int> >);
		for(int i=0;i<n;i++)
		cout << p[i].second<<endl;
		
	}
	
	
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

template <class Monoid>
struct SegTree {
  using Func = function<Monoid(Monoid, Monoid)>;
  const Func F;
  const Monoid UNITY;
  int size;
  vector<Monoid> dat;

  SegTree(int n, const Func f, const Monoid &unity)
      : F(f), UNITY(unity), size(n), dat(2 * n, unity) {}

  // Sets i-th value (0-indexed) to x for initial setup.
  // build() must be called after set() calls.
  void set(int i, const Monoid &x) { dat[size + i] = x; }
  void build() {
    for (int k = size - 1; k > 0; --k) {
      dat[k] = F(dat[k * 2], dat[k * 2 + 1]);
    }
  }

  // Sets i-th value (0-indexed) to x.
  void update(int i, const Monoid &x) {
    int k = size + i;
    dat[k] = x;
    while (k > 1) {
      k >>= 1;
      dat[k] = F(dat[k * 2], dat[k * 2 + 1]);
    }
  }

  // Queries by [l,r) range (0-indexed, open interval).
  Monoid fold(int l, int r) {
    l += size;
    r += size;
    Monoid vleft = UNITY, vright = UNITY;
    for (; l < r; l >>= 1, r >>= 1) {
      if (l & 1) vleft = F(vleft, dat[l++]);
      if (r & 1) vright = F(dat[--r], vright);
    }
    return F(vleft, vright);
  }

  // Queries by a single index (0-indexed).
  Monoid operator[](int i) { return dat[size + i]; }

  /* debug */
  void print() {
    for (int i = 0; i < size; ++i) {
      cout << (*this)[i];
      if (i != size - 1) cout << ",";
    }
    cout << endl;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, Q;
  cin >> N >> Q;
  vector<int> colors(N);
  REP(i, N) cin >> colors[i];
  vector<int> lefts(Q), rights(Q), ids(Q);
  REP(i, Q) {
    cin >> lefts[i] >> rights[i];
    --lefts[i];
    --rights[i];
    ids[i] = i;
  }
  sort(ids.begin(), ids.end(),
       [&](int i, int j) { return rights[i] < rights[j]; });

  SegTree<int> seg(
      N, [](int x, int y) { return x + y; }, 0);
  vector<int> prev(500'005, -1);
  vector<int> res(Q);
  int j = 0;
  for (int i = 0; i < N; ++i) {
    int pc = prev[colors[i]];
    if (pc >= 0) {
      seg.update(pc, seg[pc] + 1);
    }
    for (; j < Q && rights[ids[j]] == i; ++j) {
      int dup_count = seg.fold(lefts[ids[j]], N);
      res[ids[j]] = rights[ids[j]] - lefts[ids[j]] + 1 - dup_count;
      DEBUG(j, ids[j], lefts[ids[j]], rights[ids[j]], dup_count, res[ids[j]]);
    }
    prev[colors[i]] = i;
  }
  for (int i = 0; i < Q; ++i) cout << res[i] << '\n';
}


Measured memory_bytes: 19436
#include <stdio.h>

int main(){
int a, b;
    scanf("%d %d", &a, &b);
    if(a>b){
        printf("a > b\n");
    }else if(a<b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}

Measured memory_bytes: 580
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n>>k>>c>>s;
		// n=s.length();
		ll l[k],r[k];
		j=0;m=-c-5;
		rep(i,n)
		{
			if(s[i]=='o' && i-m>c)
			{
				l[j++]=i;
				m=i;
			}
			if(j==k) break;
		}
		m=n+c+5;
		j=k-1;
		for(i=n-1;i>-1;i--)
		{
			if(s[i]=='o' && m-i>c)
			{
			// debug3(i,j,m);
				r[j--]=i;
				m=i;
			}
			if(j==-1) break;

		}
		rep(i,k)
		{
			if(l[i]==r[i])
				cout<<l[i]+1<<"\n";
		}

		
		// cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 5012
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<vector>
#include<functional>
using namespace std;
typedef long long LL;
inline LL read()
{
	LL kk=0,f=1;
	char cc=getchar();
	while(cc<'0'||cc>'9'){if(cc=='-')f=-1;cc=getchar();}
	while(cc>='0'&&cc<='9'){kk=(kk<<1)+(kk<<3)+cc-'0';cc=getchar();}
	return kk*f;
}
LL cou=0,asd=0,len,k;
void dfs(LL now,int de)
{
	if(de==len)
	{
		cou++;
		if(cou==k)asd=now;
		return;
	}
	LL per=now%10;
	for(LL i=max(0ll,per-1);i<=min(9ll,per+1);++i)
	{
		dfs(now*10+i,de+1);
	}
}
int main()
{
	k=read();
	for(LL i=1;i<=10;++i)
	for(LL j=1;j<=9;++j)
	{
		len=i;
		dfs(j,1);
		if(cou>k)break;
	}
	printf("%lld\n",asd);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string ss;
	cin>>ss;
	long long len=ss.length();
	long long ans=0;
	long long num=1;
	for(int i=0;i<len;i++){
		if(ss[i]=='<'){
			if(i==len-1){
				ans+=num;
			}else if(ss[i+1]=='<'){
				ans+=num;
				num++;
			}
		}else if(ss[i]=='<'&&ss[i+1]=='>'){
			continue;
		}else if(ss[i]=='>'){
			int cnt=i+1;
			while(ss[cnt]=='>'&&cnt<len){
				cnt++;
			}
			for(int j=0;j<=cnt-i;j++){
				if(j==cnt-i&&j<num){
					ans+=num;
				}else
					ans+=j;
			}
			i+=(cnt-i-1);
			num=1;
		}
	}
	printf("%lld\n",ans);
	return 0;
} 

Measured memory_bytes: 900