akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<random>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,t,a[100010],b[100010];
    pll ab[100010];
    cin>>n>>t;
    rep(i,n){
        cin>>a[i]>>b[i];
        ab[i]=mp(a[i],b[i]);
    }
    sort(ab,ab+n);
    ll res,dp[3010];
    rep(i,n){
        ll a=ab[i].fi,b=ab[i].sc;
        repr(j,t){
            dp[min(t,j+a)] = max(dp[min(t,j+a)],dp[j]+b);
        }
    }
    cout<<dp[t]<<endl;
    return 0;
}


Measured memory_bytes: 3456
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		for(int i = 0;i < N;i ++) {
			a[i] = sc.nextInt();
		}
		int min = a[0], max = a[0];
		for(int i = 1;i < N;i ++) {
			if(min > a[i]) min = a[i];
			if(max < a[i]) max = a[i];
		}
		System.out.println(max - min);
	}

}

Measured memory_bytes: 20816
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,L = map(int,input().split())

total = L*N
for i in range(N):
    total += i

if L<=0 and L+N-1>=0:
    print(total)
elif L>0:
    print(total - L)
else:
    print(total - (L+N-1))    

Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.LinkedHashMap;

class Main {
  public static final int WHITE = 0;
  public static final int GRAY  = 1;
  public static final int BLACK = 2;
  public static int SIZE;
  public static int TIME;

  public static void main(String... args) {
    Scanner sc = new Scanner(System.in);
    SIZE = sc.nextInt();
    Map<Node, List<Integer>> graph = new LinkedHashMap<>(SIZE);

    Node node;
    int size;
    for (int i = 0; i < SIZE; i++) {
      node = new Node(sc.nextInt());
      size = sc.nextInt();
      List<Integer> elements = new ArrayList<>(size);
      for (int j = 0; j < size; j++) {
        elements.add(sc.nextInt());
      }
      graph.put(node, elements);
    }
    dfs(graph);
    print(graph);
  }

  public static void dfs(Map<Node, List<Integer>> graph) {
    for (Map.Entry<Node, List<Integer>> entry : graph.entrySet()) {
      if (entry.getKey().color == WHITE) {
        visit(entry.getKey(), graph);;
      }
    }
  }

  public static void visit(Node node, Map<Node, List<Integer>> graph) {
    node.color = GRAY;
    node.first = ++TIME;
    for (int addr : graph.get(node)) {
      Node connect = getNode(addr, graph);
      if (connect.color == WHITE) {
        visit(connect, graph);
      }
    }
    node.color = BLACK;
    node.second = ++TIME;
  }

  public static Node getNode(int value, Map<Node, List<Integer>> graph) {
    for (Map.Entry<Node, List<Integer>> entry : graph.entrySet()) {
      if (entry.getKey().value == value) {
        return entry.getKey();
      }
    }
    return null;
  }

  public static void print(Map<Node, List<Integer>> graph) {
    StringBuilder sb = new StringBuilder();
    for (Map.Entry<Node, List<Integer>> entry : graph.entrySet()) {
      Node node = entry.getKey();
      sb.append(node.value).append(' ');
      sb.append(node.first).append(' ');
      sb.append(node.second);
      System.out.println(sb);
      sb.setLength(0);
    }
  }
}

class Node {
  public int value;
  public int color;
  public int first;
  public int second;

  public Node() {
    this(0);
  }

  public Node(int value) {
    this.value = value;
  }
}



Measured memory_bytes: 28952
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    H = il()

    ret, maxheight = 0, 0
    for h in H:
        if maxheight <= h:
            ret += 1
            maxheight = max(maxheight, h)
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10064
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

int h, w, k, a[8][8], b[8][8];

int main() {
    cin >> h >> w >> k;
    for(int i = 1; i <= h; ++i)
        for(int j = 1; j <= w; ++j) {
            char input; cin >> input;
            if(input == '.') a[i][j] = 0;
            if(input == '#') a[i][j] = 1;
        }
    int ans = 0;
    for(int sth = 0; sth < (1 << h); ++sth)
        for(int stw = 0; stw < (1 << w); ++stw) {
            for(int i = 1; i <= h; ++i)
                for(int j = 1; j <= w; ++j)
                    b[i][j] = a[i][j];
            for(int i = 1; i <= h; ++i) 
                if(sth & (1 << (i - 1))) for(int j = 1; j <= w; ++j) b[i][j] = 0; 
            for(int j = 1; j <= w; ++j)
                if(stw & (1 << (j - 1))) for(int i = 1; i <= h; ++i) b[i][j] = 0;
            int cnt = 0;
            for(int i = 1; i <= h; ++i)
                for(int j = 1; j <= w; ++j)
                    if(b[i][j]) ++cnt;
            if(cnt == k) ++ans;
        }
    cout << ans << endl;
    return 0;
}

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

const long long INF = 1LL << 60;

int N;
long long h[100010];
long long dp[100010];

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

  for (int i = 0; i < 100010; i++) dp[i] = INF;

  dp[0] = 0;

  for (int i = 1; i < N; i++) {
    dp[i] = min(dp[i], dp[i - 1] + llabs(h[i] - h[i - 1]));
    if (i > 1) dp[i] = min(dp[i], dp[i - 2] + llabs(h[i] - h[i - 2]));
  }

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

  return 0;
}

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

#define PrintLn(X) cout << X << endl
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main(void)
{
	int A, B;
	cin >> A >> B;
	if(A == B){
		PrintLn("Draw");
	}else if(A == 1 || (B != 1 && A > B)){
		PrintLn("Alice");
	}else{
		PrintLn("Bob");
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
typedef unsigned long long llu;
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f  first
#define s  second
#define mp make_pair
#define pb push_back
#define ep emplace_back
#define sz(a) (int) a.size()
#define FOR(x,a,b) for (int x=a;x<=b;x++)
#define FOD(x,a,b) for (int x=a;x>=b;x--)
#define REP(x,a,b) for (int x=a;x<b;x++)
#define RED(x,a,b) for (int x=a;x>b;x--)
#define EL printf("\n")
#define debug 1
string s;
ll n;
bool kt( string s)
{
      FOR(i,0,s.size()-1)
      {
            if(i%2==0) if(s[i]!='R' && s[i]!='U' && s[i]!='D') { return false;}
            if(i%2==1){
            if(s[i]!='L' && s[i]!='U' && s[i]!='D'){ return false;}
            }

      }
return true;
}
int main()
{
	IO;
	cin>>s; n=s.size()-1;
	if(kt(s)) cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 12345678901234567

const int maxn = 1e5 + 10;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here

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

	ll x[maxn];
	ll y[maxn];

	rep(i, n) cin >> x[i];
	rep(i, m) cin >> y[i];

	ll sumx = 0, sumy = 0;

	rep(i, n)
	{
		sumx += (i*x[i] - (n - i - 1)*x[i]) % mod;
		sumx %= mod;
	}

	rep(i, m)
	{
		sumy += (i*y[i] - (m - i - 1)*y[i]) % mod;
		sumy %= mod;
	}

	cout << (sumx*sumy) % mod << endl;
	return 0;

}

Measured memory_bytes: 1792
#include <stdio.h>

int main (void){

 int x=999, y=999;
 
 while(x + y != 0){
     scanf("%d %d", &x, &y);
     if(x == 0 && y == 0)
        break;
     if(x < y){
         printf("%d %d\n", x , y);
     }else if(x >= y){
         printf("%d %d\n", y , x);
     }
 } 
 return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
  */   
   long double r;
   cin>>r;
   cout<<(22/7.0)*2.0*r<<'\n';
   
  return 0;
}

Measured memory_bytes: 3808
void main() {
    int a = readln.chomp.to!int;
    int b = readln.chomp.to!int;
    int h = readln.chomp.to!int;
    writeln((a + b) * h / 2);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
in_1 = input().split(" ")

n = int(in_1[0])
k = int(in_1[1])
s = input()
arr = []
for i in range(n):
  arr.append(s[i])


if s[k-1] == "A":
  arr[k-1] = "a"
elif s[k-1] == "B":
  arr[k-1] = "b"
else:
  arr[k-1] = "c"

s = ""
for i in range(n):
  s = s+arr[i]

print(s)

Measured memory_bytes: 3064
(R,G,B,N) = gets.split.map {|x| x.to_i}

s = 0
(N+1).times { |r|
  (N+1).times { |g|
    rem = N - r*R - g*G
    if rem >= 0
      if rem % B == 0
        s += 1
      end
    end
  }
}

puts s

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

#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define pb push_back
#define fi first
#define se second

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	int n; cin >> n;
	int a[105];
	map<string, int> m;
	rep(i, 0, n){
		cin >> a[i];
		if(a[i]<400) m["gray"]++;
		else if(a[i]<800) m["brown"]++;
		else if(a[i]<1200) m["green"]++;
		else if(a[i]<1600) m["cyan"]++;
		else if(a[i]<2000) m["brue"]++;
		else if(a[i]<2400) m["yellow"]++;
		else if(a[i]<2800) m["orange"]++;
		else if(a[i]<3200) m["red"]++;
		else if(a[i]>=3200) m["free"]++;
	}
	int ansmin = 0;
	int ansmax = 0;
	for(auto kv: m){
		ansmax++;
		if(kv.first!="free") ansmin++;
		if(kv.first=="free") ansmax += kv.second-1;
	}
	if(ansmin==0) ansmin++;
	cout << ansmin << ' ' << ansmax << endl;
	return 0;
}

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


int main() {
    string s;
    cin>>s;
    
    if(s.size()<4){
        cout << "No" << endl;
        return 0;
    }
    
    string t = s.substr(0,4);
    if(t=="YAKI")cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
  unsigned N, K;
  std::cin >> N >> K;
  std::string s;
  std::cin >> s;
  std::vector<int> cnt(N, 0);
  int idx = 0;
  for (unsigned i = 0; i < N; ++i) {
    if (s[std::max(i, 1u) - 1] != s[i]) { ++idx; }
    ++cnt[idx];
  }
  int ans = 0;
  bool odd = s[0] == '0';
  unsigned idx2 = 0;
  for (unsigned n_flipped = 0; n_flipped < K;) {
    if (idx2 >= N) { break; }
    if (odd) { ++n_flipped; }
    ans += cnt[idx2++];
    odd = !odd;
  }
  if (idx2 < N) {
    ans += cnt[idx2++];
    odd = !odd;
  }
  unsigned idx3 = s[0] == '1' ? 1 : 0;
  int ans_candidate = ans;
  for (; idx2 < N; ++idx2) {
    if (!odd) { ans_candidate += cnt[idx2]; }
    else {
      ans_candidate -= cnt[idx3];
      if (idx3) {
        ans_candidate -= cnt[idx3 - 1];
      }
      idx3 += 2;
      ans_candidate += cnt[idx2];
    }
    odd = !odd;
    ans = std::max(ans, ans_candidate);
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 896
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] cnt = new int[N+1];
		for (int i = 0; i < K; i++) {
			for (int d = sc.nextInt(); d > 0; d--) {
				cnt[sc.nextInt()]++;
			}
		}
		int ans = 0;
		for (int i = 1; i <=N; i++) {
			if(cnt[i] == 0) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 46392
#include<bits/stdc++.h>
using namespace std;
#define N 500000
#define maxn (N + 10)
#define maxm (maxn * 2)
#define pb push_back
#define lc (id * 2)
#define rc (id * 2 + 1)
#define Mod(x) (((x) % mod + mod) % mod)
typedef long long ll;
const ll INF = (1e8);
const ll mod = (1e9 + 7);
ll pw[maxn],iv[maxn];
ll f_pow(ll x,ll p){
    ll ans = 1;
    while(p){
        if(p % 2 == 1){
            ans *= x;ans %= mod;
        }
        x *= x;x %= mod;p /= 2;
    }
    return ans;
}
void init(){
    pw[0] = 1;
    for(ll i = 1;i <= N;i++){
        pw[i] = pw[i - 1] * i;pw[i] %= mod;
    }
    iv[N] = f_pow(pw[N],mod - 2);
    //printf("iv[N] = %lld\n",iv[N]);
    for(ll i = N - 1;i >= 0;i--){
        iv[i] = iv[i + 1] * (i + 1);iv[i] %= mod;
    }
    //iv[0] = 1;
    //printf("iv0 = %lld\n",iv[0]);
}
ll C(ll x,ll y){
    ll ans = pw[x];ans *= iv[y];ans %= mod;ans *= iv[x - y];ans %= mod;
    return ans;
}
int main(){
    init();
    ll n,m;scanf("%lld%lld",&n,&m);
    ll ans = 0;
    for(ll i = 0;i <= n;i++){
        ll cnt = ((i % 2 == 0) ? 1 : -1);
        //printf("cnt1 = %lld\n",cnt);
        cnt *= C(m,i);cnt = Mod(cnt);
        //printf("cnt2 = %lld\n",cnt);
        cnt *= C(n,i);cnt = Mod(cnt);
        //printf("cnt3 = %lld\n",cnt);
        cnt *= pw[i]; cnt = Mod(cnt);
        //printf("cnt4 = %lld\n",cnt);
        cnt *= C(m - i,n - i);cnt = Mod(cnt);
        //printf("cnt5 = %lld\n",cnt);
        cnt *= pw[n - i];cnt = Mod(cnt);
        //printf("cnt6 = %lld\n",cnt);
        cnt *= C(m - i,n - i);cnt = Mod(cnt);
        //printf("cnt7 = %lld\n",cnt);
        cnt *= pw[n - i];cnt = Mod(cnt);
        ans += cnt;ans %= mod;
        //printf("ans = %lld cnt = %lld\n",ans,cnt);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 11636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if((a==1 && b==2)||(a==2 && b==1))
    {
        cout<<3<<endl;
    }
if((a==2 && b==3)||(a==3 && b==2))
    {
        cout<<1<<endl;
    }

if((a==1 && b==3)||(a==3 && b==1))
    {
        cout<<2<<endl;
    }



}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<numeric>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<ctype.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
//----------program from here----------

int ctoi(char c) {
  if('0'<=c && c <= '9') return c-'0';
  return 0;
}

int main(){
  int r = 0;
  cin >> r;
  if(r<1200){
    cout << "ABC" << endl;
  }else if(r<2800){
    cout << "ARC" << endl;
  }else{
    cout << "AGC" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int Mod=1e9+7;
int h,w,f[1010][1010];
char s[1010][1010];
int main()
{
	scanf("%d%d",&h,&w);
	for (int i=1;i<=h;i++)
	{
		scanf("%s",&s[i]);
	}
	f[1][1]=1;
	s[1][0]='#';
	for (int i=1;i<=h;i++)
	{
		for (int j=1;j<=w;j++)
		{
			if (s[i][j-1]=='#')
			{
				continue;
			}
			f[i][j]=(f[i-1][j]+f[i][j-1])%Mod;
		}
		/*
		for (int j=1;j<=w;j++)
		{
			cerr<<f[i][j]<<" ";
		}
		cerr<<endl;
		*/
	}
	cout<<f[h][w]<<endl;
	return 0;
}


Measured memory_bytes: 5120
#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(){
    int x, a;
    cin >> x >> a;
    if(x < a) cout << 0 << endl;
    else cout << 10 << endl;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define en '\n'
#define pb push_back
#define mp make_pair
#define P pair<int, int>

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;

struct aaa {
	aaa() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
}aaaaa;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << a * b / 2 << endl;
}

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

using namespace std;

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

    cin >> a >> b >> c >> d;

    if( (abs(a-b) <= d && abs(b-c) <= d) || abs(a-c) <= d ){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
n,m,c = map(int,input().split())
B = list(map(int,input().split()))
ans = 0
for i in range(n):
  A = list(map(int,input().split()))
  q = c
  for j in range(m):
    q += A[j]*B[j]
  if q > 0:
    ans += 1

print(ans)

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

template <typename T>
void SieveOfEratosthenes(T& v, int n){
    vector<bool> l(n+1, true);
    for (int i = 2; i <= n; i++){
		if (!l[i]) continue;

		v[i] = true;
		for (int j = 2; i*j <= n; j++){
	    	l[i*j] = false;
		}
    }
}

int main(){
	const int size = 100000;
	array<bool, size+10> v;
	v.fill(false);
	SieveOfEratosthenes(v, size);

	array<int, size+10> x;
	x.fill(0);
	for (int i = 2; i <= size; i++){
		x[i] += x[i-1];
		if (v[i] && v[(i+1)/2]) x[i]++;
	}

	int Q;
	cin >> Q;
	vector<int> l(Q);
	vector<int> r(Q);
	for (int i = 0; i < Q; i++){
		cin >> l[i] >> r[i];
	}

	for (int i = 0; i < Q; i++){
		cout << x[r[i]]-x[l[i]-1] << endl;
	}

	return 0;
}


Measured memory_bytes: 1920
import Data.Char
import Data.List
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as U

main = do
  [n,m] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  d <- sequence $ replicate m $ do
    _:ss <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return ss
  ps <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let result = sum $ do
        t <- U.replicateM n [0,1]
        forM_ (zip d ps) $ \(ss,p) -> do
          guard $ (sum (map ((t U.!) . subtract 1) ss) `rem` 2) == p
        return 1
  print result


Measured memory_bytes: 1020
n = int(input())
num = list(map(int, input().split()))
cnt = 0
for i in range(1, n - 1) :
  if num[i - 1] > num[i] & num[i] > num[i + 1] :
    cnt += 1
  elif num[i - 1] < num[i] & num[i] < num[i + 1] :
    cnt += 1
print(cnt)


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

int main() {
  string s, t;
  cin >> s >> t;
  int c=0;
  for(int i=0; i < s.size(); i++){
    if(s.at(i) != t.at(i)){
      c++;
    }
  }
  if(c == 0){
    cout << "Yes"<<endl;
  }else{
    cout << "No"<<endl;
  }
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {

	public static void main(String[] args) {

		 Scanner scan = new Scanner(System.in);
		 int a = scan.nextInt();
		 int b = scan.nextInt();
		 int x = scan.nextInt();
		 
		 if(a <= x && a + b >= x) {
			 System.out.println("YES");
		 } else { 
			 System.out.println("NO");
		 }
	}
}

Measured memory_bytes: 21844
// import chie template :) {{{
import std;

// }}}
// nep.scanner {{{
class Scanner {
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType)) {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0) {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }

  void scan()() {
  }

  void scan(T, S...)(ref T x, ref S args) {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType)) {
    str ~= s.to!(char[]).strip.split;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  writeln(iota(1, cin.next!long() + 1).filter!"a % 3 != 0 && a % 5 != 0".sum);
}


Measured memory_bytes: 3220
// Problem : A - αlphabet
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vstr vector<string>
#define vdb vector<double>
#define vbool vector<bool>
#define vvi vector<vector<int> >
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define vpair vector<pii > 
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<<a[i]<<' ';}cout<<'\n'
#define mem(a,v) memset(a,v,sizeof(a))
#define loop(i,a,b) for (int i = a; i < b; i++)
#define loope(i,a,b) for (int i = a; i <= b; i++)
#define bloop(i,a,b) for(int i = a;i>=b;i--)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(9)
#define PI 3.14159265
#define S second
#define F first
#define CHECK cout<<"CHEDEDWB"<<endl
#define CHECK1(a) cout<<a<<endl
#define CHECK2(a,b) cout<<a<<' '<<b<<endl;
#define br '\n'
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(),x.end()
using namespace std;
int mod = 1e9+7;
int inf = 1e18;
int m_inf = INT_MIN;
// int extendedgcd(int a,int b,int &x,int &y){
	// if(a == 0){
		// x = 0; y = 1;
		// return b;
	// }
	// int x1,y1;
	// int d = extendedgcd(b%a,a,x1,y1);
	// x = y1 - (b/a)*x1;y = x1;
	// return d;
// }
// int expmod(int a,int b) {
// 	if(b == 1) return a;
// 	if(b == 0) return 1;
// 	int m1 = expmod(a,b/2)%mod;
// 	if(b%2) return ((m1*m1)%mod*a%mod)%mod;
// 	return (m1*m1)%mod;
// }
// int power(int a,int b) {
// 	if(b == 1) return a;
// 	if(b == 0) return 1;
// 	int m1 = power(a,b/2);
// 	if(b%2) return m1*m1*a;
// 	return m1*m1;
// }
// int logn(int n, int r) 
// { 
//     return (n > r - 1) ? 1 + logn(n / r, r) : 0; 
// } 

// int nCr(int n,int r)
// {
	// r = min(r,n-r);
	// if(r<0)
		// return 0;
	// if(r == 0)
		// return 1;
	// int ans = 1;
	// for(int i = 1;i<=r;i++)
	// {
		// ans = ans*(n-i+1)/i;
	// }
	// return ans;
// 		
// }
// vi factmod(int n)
// {
	// vi ans(n+1);
	// ans[0] = 1;
	// loop(i,1,n+1)
	// {
		// ans[i] = (ans[i-1]*i)%mod;
	// }
	// return ans;
// }
// int nCrmod(int n,int r,vi &fact)
// {
	// int x1,y1;
	// extendedgcd(fact[r],mod,x1,y1);
	// int x2,y2;
	// extendedgcd(fact[n-r],mod,x2,y2);
	// int ans = (fact[n]*((x1+mod)%mod))%mod;
	// ans = (ans*((x2+mod)%mod))%mod;
	// return ans;
// }

// void dfs(vector<vector<int> > &adj,int root,vbool &vis)
// {
// 	vis[root] = true;
// 	for(int i = 0;i<adj[root].size();i++){
// 		int v = adj[root][i];
// 		if(!vis[v])		
// 			dfs(adj,v,vis);
// 	}
// }

int32_t main() 
{
	FastIO; PRECISION;
	int t = 1;
	// cin>>t;
	while(t--)
	{
		char ch;
		cin>>ch;
		if(ch>='A' && ch<='Z')
			cout<<'A';
		else
			cout<<'a';
		
		
		
		
	}
}

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

#define REP(i,n)    for(int i = 0; i < (int)n; i++)
#define MAX_N   100000
#define MAX_M   100000


void solve(){
    char S[3];
    cin >> S;
    if(S[0]==S[1]&&S[1]==S[2])
        cout << "No\n";
    else
        cout << "Yes\n";
    
}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2147483647
#define inf 1000000007
#define lol long long
#define in(n,s) insert(n,s)//ノート参照
#define SYOU(x) setprecision(x)
#define abs(x,y) (max(x,y)-min(x,y))
#define mp make_pair
#define fi first
#define se second
using namespace std;
int gcd(int x,int y){//最大公約数
  if(y>x) swap(x,y);
  int r=x%y;
  while(r!=0){
    x=y;
    y=r;
    r=x%y;
  }
  return y;
}
int Lcm(int x,int y){//最小公倍数
  int t=x*y;
  return t/gcd(x,y);
}
priority_queue<int> i[300000];
bool ma[100],ma2[100];
lol a,b,c,d,g,h;
bool can(int n,int m){
  if(n<0) return false;
  if(m<0) return false;
  if(n>=a) return false;
  if(m>=b) return false;
  return true;
}
int dfs(int n,int m){
  if(n==g&&m==h) return true;
  //if(i[n][m]!=i[c][d]||!can(n,m)||ii[n][m]) return false;
  //ii[n][m]=true;
  return dfs(n+1,m)+dfs(n,m+1)+dfs(n-1,m)+dfs(n,m-1);
}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long e=0,f=0,j=1;
  string w,p;
  cin >>a;
  if(a==1) cout <<"Hello World\n";
  else{
    cin >>a>>b;
    cout <<a+b<<'\n';
  }
  return (0);
}


Measured memory_bytes: 9600
s=input()
l=[]
alf=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o",
"p","q","r","s","t","u","v","w","x","y","z"]
for x in alf:
    if str(x) in s:
        pass
    else:
        l.append(x)
if l==[]:
    print("None")
else:
    print(min(l))


Measured memory_bytes: 39024
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define int long long

const int MAX = 200100;
int BIT[MAX];
void add(int i, int n) {
  while (i < MAX) {
    BIT[i] += n;
    i += i & -i;
  }
}
int sum(int i) {
  int res = 0;
  while (i > 0) {
    res += BIT[i];
    i -= i & -i;
  }
  return res;
}
void clear() {
  for (int i = 1; i < MAX; i++)
    BIT[i] = 0;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int l = 0, r = 1e9;
  const ll all = (n+1)*n/2;
  while (r-l > 1) {
    int mid = (l+r)/2;
    vector<int> b(n), s(n+1);
    rep(i, n) b[i] = (a[i]<=mid ? 1 : -1);
    rep(i, n) s[i+1] = s[i]+b[i];
    rep(i, n+1) s[i] += n+1;
    add(s[0], 1);
    int num = 0;
    for (int i = 1; i <= n; i++) {
      num += sum(s[i]-1);
      add(s[i], 1);
    }
    clear();
    if (num >= all/2+1)
      r = mid;
    else
      l = mid;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 4232
S = input()
c = ''
if S[0] == '1':
  c += '9'
elif S[0] == '9':
  c += '1'
else:
  c += S[0]
if S[1] == '1':
  c += '9'
elif S[1] == '9':
  c += '1'
else:
  c += S[1]
if S[2] == '1':
  c += '9'
elif S[2] == '9':
  c += '1'
else:
  c += S[2]
print(c)

Measured memory_bytes: 3060
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N = NI()
    A = []
    B = []
    for _ in range(N):
        a,b = LI()
        A.append(a)
        B.append(b)

    A.sort()
    B.sort(reverse=True)

    if N % 2:
        i = A[N//2]
        j = B[N//2]
        print(j-i+1)
    else:
        i1 = A[N//2-1]
        i2 = A[N//2]
        j1 = B[N//2-1]
        j2 = B[N//2]

        x1 = j1 - i1
        x2 = j2 - i2
        ans = x1 + x2 + 1
        print(ans)


if __name__ == '__main__':
    main()

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

int main(){
  ll ans = 0,N;
  cin >> N;
  string S; cin >> S;
  rep(i,S.size()-2){
    if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C'){
      ans++;
    }
  }
  cout << ans;
}

Measured memory_bytes: 3600
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    string_code(1, S, C),
*/

main:-
    get_number(N),
    get_number(M),
    N =:= M -> writeln("Yes") ; writeln("No").


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

long long a[200005],b[200005];

int main()
{
    int n,i;
    long long ans=0,m=1000000007;

    cin>>n;

    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
        b[i]=b[i-1]+a[i];
    }
    for(i=1;i<=n;i++){
        ans=(ans+((b[i-1]%m)*(a[i]%m))%m)%m;
    }
    cout<<ans<<"\n";

    return 0;
}





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

int main(){
  int64_t N,M;
  cin >> N >> M;
  vector<pair<int64_t,int64_t>> P(N);
  for(int64_t i=0;i<N;i++){
    int64_t a,b;
    cin >> a >> b;
    P.at(i) = make_pair(a,b);
  }
  
  sort(P.begin(),P.end());
  int64_t answer = 0;
  for(int64_t i=0;i<N;i++){
    if(P.at(i).second<=M){
      answer += P.at(i).first * P.at(i).second;
      M -= P.at(i).second;
    }
    else{
      answer += P.at(i).first * M;
      break;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 1792
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int n;
string s[40];
bool f[1000];

int main(){
  while (cin >> n, n){
    rep(i, n) cin >> s[i];
    rep(i, n){
      int t = 0;
      memset(f, 0, sizeof f);
      rep(j, i, n){
        t += s[j].size();
        f[t] = true;
      }
      if (f[5] && f[12] && f[17] && f[24] && f[31]){
        cout << i + 1 << endl;
        goto B;
      }
    }
    B:;
  }
}

Measured memory_bytes: 3204
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

vector<vector<int>>fi;

vector<vector<long long int>>spt, got;

struct aa {
	int y;
	int x;
	int time;
};
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };


class Compare {
public:
	//keiroが昇順に並ぶ
	bool operator()(const aa&l, const aa&r) {
		return l.time>r.time;
	}
};

int main() {
	int W, H; cin >> W >> H;
	int sx, sy;
	pair<int, int>gp;
	vector<pair<int, int>>sps;
	fi.resize(H);
	spt.resize(H);
	got.resize(H);
	for (int i = 0; i < H; ++i) {
		
		string st; cin >> st;
		for (int j = 0; j < W; ++j) {
			spt[i].emplace_back(9999999999);
			got[i].emplace_back(9999999999);
			int wh;
			if (st[j] == '.') {
				wh = 0;
			}
			else if (st[j] == '#') {
				wh = 1;
			}
			else if (st[j] == '*') {
				wh = 2;
				sps.push_back(make_pair(i, j));
			}
			else if (st[j] == 's') {
				wh = 0;
				sx = j; sy = i;
			}
			else if (st[j] == 'g') {
				wh = 4;
				gp.first = i;
				gp.second = j;
			}
			else {
				assert(false);
			}
			fi[i].push_back(wh);
		}
	}
	{
		priority_queue<aa, vector<aa>, Compare>que;
		for (int i = 0; i < sps.size(); ++i) {
			que.push(aa{ sps[i].first, sps[i].second, 0 });
			spt[sps[i].first][ sps[i].second] = 0;
		}

		while (!que.empty()) {
			aa atop(que.top());
			que.pop();
			for (int i = 0; i < 4; ++i) {
				const int nx = atop.x + dx[i];
				const int ny = atop.y + dy[i];
				const int nt = atop.time + 1;
				if (!fi[ny][nx]) {
					if (spt[ny][nx] > nt) {
						spt[ny][nx] = nt;
						que.push(aa{ ny,nx,nt });
					}
				}
			}

		}
	}
	{
		priority_queue<aa, vector<aa>, Compare>que;
		que.push(aa{ gp.first, gp.second, 0 });
		got[gp.first][gp.second] = 0;
		

		while (!que.empty()) {
			aa atop(que.top());
			que.pop();
			for (int i = 0; i < 4; ++i) {
				const int nx = atop.x + dx[i];
				const int ny = atop.y + dy[i];
				const int nt = atop.time + 1;
				if (!fi[ny][nx]) {
					if (got[ny][nx] > nt) {
						got[ny][nx] = nt;
						que.push(aa{ ny,nx,nt });
					}
				}
			}

		}
	}

	__float128 amin = 0;
	__float128 amax = 1e11;
	bool ok = true;
	while (amin + 1e-10 < amax) {
		__float128 amid = (amin + amax) / 2;

		__float128 timesum = 0;
		__float128 placesum = 0;
		for (int y = 0; y < H; ++y) {
			for (int x = 0; x < W; ++x) {
				if (!fi[y][x]) {
					if (got[y][x] == 9999999999 && spt[y][x] == 9999999999) {
						ok = false;
						break;
					}
					placesum++;
					timesum += min(static_cast<__float128>(got[y][x]), spt[y][x] + amid);
				}
			}
		}
		if (amid < timesum / placesum) {
			amin = amid;
		}
		else {
			amax = amid;
		}
	}
	long double ans;
	if (ok) {
		ans = min(static_cast<__float128>(got[sy][sx]), spt[sy][sx] + amin);

	}
	else {
		ans = static_cast<long double>(got[sy][sx]);
	}
	cout <<fixed<<setprecision(22)<< ans << endl;
	return 0;
}

Measured memory_bytes: 8444
#include <bits/stdc++.h>
#include <set>
#include <math.h>
#include <random>
#define PI 3.14159265359
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define Rep(i, k, n) for(int i = k; i < (int)n; i++)
using namespace std;

int main(){
  while(true){
    int n;
    cin >> n;
    if (n == 0){break;}
    int w[n];
    rep(i, n){
      cin >> w[i];
    }
    int dp2[n][n];
    rep(i,n){
      rep(j,n){
        dp2[i][j] = 0;
      }    
    }
    
    Rep(i, 1, n) {
      rep(j, n-i) {
        if (dp2[j+1][j+i-1] == i-1 && abs(w[j]-w[j+i]) <= 1) {
          dp2[j][j+i] = dp2[j+1][j+i-1]+2;
        }
        rep(k, i) {
          dp2[j][j+i] = max(dp2[j][j+i], dp2[j][j+k] + dp2[j+k+1][j+i]);
        }
      }
    }
    cout << dp2[0][n-1] << endl;
  }
}


Measured memory_bytes: 3440
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  vector<ll> data(26, 0);
  for(int i = 0; i < N; i++){
    data[S[i] - 'a']++;
  }
  ll ans = 1;
  for(int i = 0; i < 26; i++){
    if(data[i]) ans = (ans * (data[i] + 1LL)) % mod;
  }
  cout << ans - 1 << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <stdio.h>
typedef long long int LL;
#define fr(i,p,n) for(LL i=p;i<n;i++)
#define fr1(i,p,n) for(LL i=p;i>=n;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define precise cout << std::setprecision(10) << std::fixed;

using namespace std;
 
int main()
{
        LL n;
        cin>>n;
        LL a[n];
        map<LL,LL> mp;
        LL ans=0;
        fr(i,0,n){
        cin>>a[i];
        mp[a[i]]++;
        ans+=a[i];
        } 
        LL q;
        cin>>q;
        LL x,y;
        fr(i,0,q)
        {
            cin>>x>>y;
          ans-=x*mp[x];
          ans+=y*mp[x];
          mp[y]+=mp[x];
          mp[x]=0;
           cout<<ans<<endl;
        }
         
    return 0;
}

Measured memory_bytes: 10060
dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]


def dfs(x, y, cnt):
    global board, W, H, ans
    if cnt >= ans:
        return

    for i in range(4):
        mx = x + dx[i]
        my = y + dy[i]

        if 0 > mx or 0 > my or W <= mx or H <= my:
            continue
        if board[my][mx] == 1:
            continue

        while True:
            if board[my][mx] == 3:
                ans = cnt
                return

            mx += dx[i]
            my += dy[i]

            if 0 > mx or 0 > my or W <= mx or H <= my:
                break

            if board[my][mx] == 1:
                board[my][mx] = 0
                dfs(mx - dx[i], my - dy[i], cnt + 1)
                board[my][mx] = 1
                break

while True:
    W, H = map(int, raw_input().split())
    if W == 0:
        break

    ans = 11
    board = [map(int, raw_input().split()) for _ in range(H)]
    for y in range(H):
        for x in range(W):
            if board[y][x] == 2:
                sx, sy = x, y
    dfs(sx, sy, 1)
    print ans if ans < 11 else - 1

Measured memory_bytes: 6380
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
using vi = vector<int>;
const int MOD = 1e9+7;
 
 
int main() {
	int K,S;
  	cin >> K >> S;
  	int sum = 0;
  	rep(x,K+1){
    	rep(y,K+1){
        	if(x+y >= S-K &&x+y <= S) sum = sum+1;
        }
    }
  	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O999")
#define long long ll
const int INF=0x3f3f3f3f;
int maxn=50000005;
using namespace std;

int main(){
	//freopen(".in", "r",stdin );
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	cout<<pow(n,3)<<endl;
	return 0;
}

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

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

  int count = 0;
  for (int i = 0; i < S.size(); ++i) {
    if (S.at(i) == T.at(i)) { ++count; }
  }
  cout << count << endl;
}

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

int main()
{
  int arr[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;cin >> k;
  cout << arr[k-1];
}


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

#define f(x, y, z) for (int x = (y), __ = (z); x < __; ++x)
#define _rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define mst(x, a) memset(x, a, sizeof(x))

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
const int INF = 1 << 27;
const ll LLINF = (ll)1 << 60;
const ll MOD = 1e9 + 7;

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

const int MAXN = 301;
int N;
bool vis[MAXN][MAXN][MAXN] = {};
double dp[MAXN][MAXN][MAXN];

double calc(int b, int c, int d) {
  if (vis[b][c][d]) return dp[b][c][d];
  vis[b][c][d] = true;

  double sum = b + c + d;
  double ans = N / sum;
  if (b) ans += b * calc(b - 1, c, d) / sum;
  if (c) ans += c * calc(b + 1, c - 1, d) / sum;
  if (d) ans += d * calc(b, c + 1, d - 1) / sum;
  return dp[b][c][d] = ans;
}

int main() {
  scanf("%d", &N);
  int cnt[4] = {};
  for (int i = 0; i < N; i++) {
    int x;
    scanf("%d", &x);
    cnt[x]++;
  }

  dp[0][0][0] = 0;
  vis[0][0][0] = true;
  printf("%.10lf\n", calc(cnt[1], cnt[2], cnt[3]));
}


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


using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    
    string s[H + 1];
    
    int cnt = 0;
    int d[60][60];
    int INF = 100000;
    
    for(int i = 0; i < H; ++i){
        cin >> s[i];
        for(int j = 0; j < W; ++j){
            d[i][j] = INF;
            if(s[i][j] == '#'){
                ++cnt;
                
            }
        }
    }
    
    queue <pair<int, int>> que;
    
    que.push(make_pair(0, 0));
    
    int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
    
    d[0][0] = 1;
    
    while(que.size() > 0){
        pair<int, int>p = que.front(); que.pop();
        
        int px = p.first, py = p.second;
        
        for(int i = 0; i < 4; ++i){
            int nx = px + dx[i];
            int ny = py + dy[i];
            
            if(d[nx][ny] != INF | nx >= H | ny >= W | s[nx][ny] == '#'){
                continue;
            } else {
                d[nx][ny] = d[px][py] + 1;
                que.push(make_pair(nx, ny));
                
                if(nx == H - 1 && ny == W - 1){
                    int ans = H * W - cnt - d[nx][ny];
                    cout << ans << endl;
                    return 0;
                }
            }
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <ctype.h>
#include <vector>
using namespace std;

string solve(vector<string> v,char t){
	string ret;
	switch(t){
	case 'U':
		for(int i=0;i<v.size();i++){
			for(int j=0;j<v[i].length();j++){
				v[i][j] = tolower(v[i][j]);
			}
			v[i][0] = toupper(v[i][0]);
			ret += v[i];
		}
		return ret;
	case 'L':
		for(int i=0;i<v.size();i++){
			for(int j=0;j<v[i].length();j++){
				v[i][j] = tolower(v[i][j]);
			}
			if(i)v[i][0] = toupper(v[i][0]);
			ret += v[i];
		}
		return ret;
	case 'D':
		for(int i=0;i<v.size();i++){
			if(i)ret+="_";
			for(int j=0;j<v[i].length();j++){
				v[i][j] = tolower(v[i][j]);
			}
			ret+=v[i];
		}
		return ret;
	}
}

int main(){
	char type;
	string s;
	string t;
	while(cin >> s >> type,type != 'X'){
		vector<string> data;
		if(~s.find("_")){
			for(int i=0;i<s.length();i++){
				if(s[i]=='_'){
					s[i] = ' ';
				}
			}
			stringstream ss(s);
			while(ss >> t)data.push_back(t);
		}else{
			for(int i=0;i<s.length();i++){
				if(isupper(s[i])){
					s.insert(i," ");
					i++;
				}
			}
			stringstream ss(s);
			while(ss >> t)data.push_back(t);
		}
		cout << solve(data,type) << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
long long n;
long long l[86];
int main(){
	l[0]=2;
	l[1]=1;
	cin>>n;
	if(n<2){
		cout<<l[n]<<endl;
		return 0;
	}
	for(int i=2;i<=n;i++){
		l[i]=l[i-1]+l[i-2];
	}
	cout<<l[n]<<endl;
	return 0;
}

Measured memory_bytes: 256
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.split_whitespace();
	let k:i32 = match iter.next().unwrap().parse() {
		Ok(n) => n,
		Err(_) => panic!(""),
	};
	let x:i32 = match iter.next().unwrap().parse() {
		Ok(n) => n,
		Err(_) => panic!(""),
	};
	for n in (x-k+1)..(x+k) {
		print!("{} ", n);
	}
	print!("\n");
}

Measured memory_bytes: 4352
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var s = ReadLine();
            var gnum = s.Count(c => c == 'g');
            var pnum = s.Count(c => c == 'p');
            WriteLine((gnum - pnum) / 2);
        }
    }
}

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

int main(){
    
    int n, k; cin >> n >> k;
    string s; cin >> s;
    int ok = 0, notok = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'L' and i-1 >= 0 and s[i-1] == 'L') ok++;
        else if(s[i] == 'R' and i+1 < n and s[i+1] == 'R') ok++;
        else notok++;
    }
    for(int i = 0; i < k; i++){
        if(notok == 1) break;
        else if(notok == 2) ok++, notok--;
        else notok -= 2, ok += 2;
    }
    cout << ok << endl;
    return 0;
}

Measured memory_bytes: 512
n = int(input())
memo = [None]*(n+1)

def Fib(n):
    if n==0 or n==1:
        return 1
    elif memo[n]:
        return memo[n]
    else:
        r=Fib(n-1)+Fib(n-2)
        memo[n]=r
        return r
print(Fib(n))


Measured memory_bytes: 5600