akhauriyash/Code-Regression huggingface dataset:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


s = input()
n = len(s)
a = [None]*n
c = 0
v = 1
for i in range(n-1, -1, -1):
    c = (c + v*int(s[i])) % 2019
    a[i] = c
    v *= 10
    v %= 2019
from collections import Counter
cc = Counter(a)
ans = 0
for k,v in cc.items():
    ans += v*(v-1)//2
ans += cc[0]
print(ans)

Measured memory_bytes: 73220
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;
long long INF = 1LL << 60;
int main() {
	int N;
	string S;
	cin >> N >> S;
	int ans = 1;
	for (int i = 0; i < S.size() - 1; i++) {
		if (S[i + 1] != S[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3744
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
    // input from txt （提出時にこの箇　所は削除すること）
    ifstream in("Input.txt");
    cin.rdbuf(in.rdbuf());
 
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    /////////////////////
    // Write code below /
    int X;
    cin >> X;
    
    if(X >= 30){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    /////////////////////
 
 
    return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

// all_ofを使ってみたかったver

int n, m;
vector<int> s[10];
int p[10];
int on[10] = {0};

int dfs(int i) {
    //cerr << i << ' ' << n << '\n';
    if (i == n) {
        int idx[m]; iota(idx, idx+m, 0);
        bool yes = all_of(idx, idx+m, [&](int j) {
            int sum=0;
            for (auto sjk : s[j]) sum += on[sjk];
            return sum % 2 == p[j];
        });
        return (int)yes;
    } else {
        int a, b;
        on[i] = 0;
        a = dfs(i + 1);
        on[i] = 1;
        b = dfs(i + 1);
        return a + b;
    }
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int k; cin >> k;
        for (int j = 0; j < k; j++) {
            int sij; cin >> sij;
            s[i].push_back(sij - 1);
        }
    }
    for (int i = 0; i < m; i++) cin >> p[i];
    cout << dfs(0) << '\n';
    return 0;
}


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

int main() {
    int x;
    cin >> x;
    if (x < 1200) {
        cout << "ABC" << endl;
    } else {
        cout << "ARC" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int gcd(int a, int b);

int main(){
    long long int a, b, c, d;
    long int i = 0;
    long long int cnt, cnt1;

    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

    cnt = b;

    cnt -= b / c;
    cnt -= b / d;

    cnt += b / ((c * d) / gcd(c, d));


    cnt1 = a - 1;

    cnt1 -= (a - 1) / c;
    cnt1 -= (a - 1) / d;

    cnt1 += (a - 1) / ((c * d) / gcd(c, d));

    cnt -= cnt1;

    printf("%lld\n", cnt);

    return 0;

}

int gcd(int a, int b){
    int temp;

    if(a<b){
        temp = a;
        a = b;
        b = temp;    
    }

    int r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

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

int main()
{
    vector<string> s(3);
    cin >> s[0] >> s[1] >> s[2];
    int turn = 0, turn_old;
    while (1)
    {
        turn_old = turn;
        if (s[turn_old].empty())
        {
            char win = turn_old + 'A';
            cout << win << endl;
            return 0;
        }
        turn = s[turn_old][0] - 'a';
        s[turn_old].erase(s[turn_old].begin());
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll n, l;
  cin >> n >> l;
  if((l-1)>=0){
    cout << n*(l-1)+(n*(n+1))/2-l;
  } 
  if((l-1)<0 && abs(l-1)<=n){
    cout << n*(l-1)+(n*(n+1))/2;
  }
  if((l-1)<0 && abs(l-1)>n){
    cout << n*(l-1)+(n*(n+1))/2 -l -n+1;
  }
  
  
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	long long a, b, c;
  	cin >> a >> b >> c;
  	long long m = min(a, c);
  	a -= m; c -= m;
  	m = min(b, c);
  	b -= m;
  	cout << a << " " << b << endl;
  	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define fast ios_base:: sync_with_stdio( false ); cin.tie(0); cout.tie(0);
#define eb              emplace_back
#define em              emplace
#define pb              push_back
#define Mp              make_pair
#define ff              first
#define ss              second
#define mod 1000000007
typedef long long ll;
using namespace std;

const int M = (int)(2e6 + 239);

int getnum(string a)
{
    int i,p=0;
    rep0(i,a.size())
    {
        p*=10;
        p+=a[i]-'0';
    }
    return p;
}

int main()
{
    fast

    ll a;
    cin>>a;
    ll sum=0;
    for(int i=1; i<=a; i++)
    {
        if(i%3!=0 && i%5!=0)
        {
            sum+=i;
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 3668
/// Code by Leonardo16
///   “It is not the strength of the body, but the strength of the spirit.”   —  J.R.R. Tolkien
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
/// Macros
#define int long long
#define ll long long
#define sz size
#define ull unsigned long long
#define ld long double
#define ii pair<int,int>
#define fst first
#define scd second
#define vi vector<int>
#define vii vector<ii>
#define pb push_back
#define pf push_front
#define fl '\n'
#define el endl
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
/// Functions
#define db(x) cerr << #x << ": " << (x) << '\n';
#define random() __builtin_ia32_rdtsc()
#define lg2(x) 31-__builtin_clz(x)
#define lg2ll(x) 63-__builtin_clzll(x)
#define pi acos(-1)
#define YN(x) cout<<((x)?("YES"):("NO"))<<fl;
#define yn(x) cout<<((x)?("Yes"):("No"))<<fl;
/// Red-Black Tree Template
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
//#define less_than(n) order_of_key(n)
//#define en_pos(n) find_by_order(n)
/// Prime numbers  173,179,311,331,737,1009,2011,2027,3079,4001,100003
///=====================================================================


main(){
    ios_base::sync_with_stdio(0);cin.tie(0);

   char c;
   cin>>c;
   if(c>='A'&&c<='Z'){
        cout<<"A";
   }else{
        cout<<"a";
   }

return 0;}







Measured memory_bytes: 3616
import java.util.*;
class Main{
	static Scanner s = new Scanner(System.in);
	public static void main(String[] args) {
		char[] in = s.next().toCharArray();
		for(int i=0;i<in.length;i++)
			in[i]=(char) (((in[i]-'A'-3+26)%26)+'A');
		System.out.println(Arrays.toString(in).replaceAll("[\\[,\\] ]",""));
	}
}

Measured memory_bytes: 26864
fn main() {
    read_line().unwrap(); // n
    let l2 = read_line().unwrap();
    let l2 = l2.split_whitespace().map(|s| { s.parse::<i32>().unwrap()});
    let mut evens = l2.filter(|n| { n % 2 == 0});
    println!("{}", if evens.all(|n| { n % 3 == 0 || n % 5 == 0}) {"APPROVED"} else {"DENIED"});
}

fn read_line() -> Option<String> {
    let stdin = std::io::stdin();
    let mut buf = String::new();
    match stdin.read_line(&mut buf) {
        Ok(_) => Some(String::from(buf.trim())),
        Err(_) => None
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long int
#define ld long double 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;
 ld dp[310][310][310];

int main()
{ 
    fast;
    ll n,x;
    cin>>n;

    vector<ll> c(3,0);

    for(ll i=0;i<n;i++)
    	{
    		cin>>x;
    		c[x-1]++;
    	}
    memset(dp,0,sizeof(dp));

    for(ll k=0;k<310;k++)
    {
    	for(ll j=0;k+j<310;j++)
    	{
    		for(ll i=0;i+j+k<310;i++)
    		{
                   if(i==0 and j==0 and k==0)
    				continue;

    			ld total=i+j+k;
    			ld a1=n/total,a2=i/total,a3=j/total,a4=k/total;

    			dp[i][j][k]+=a1;
    			if(i) dp[i][j][k]+=(dp[i-1][j][k]*a2);

    			if(j) dp[i][j][k]+=(dp[i+1][j-1][k]*a3);

    			if(k)dp[i][j][k]+=(dp[i][j+1][k-1]*a4);	
    		}
    	}
    }
    cout<<fixed<<setprecision(12)<<dp[c[0]][c[1]][c[2]]<<endl;
  }

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

int main(){
  int N;
  cin >>N;
  int r=0;
  int m=N;

  while(m>0){
   r+=m%10;
   m/=10;
  }
 
   if(N%r==0) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
  
return 0;
}



Measured memory_bytes: 3636
n = gets.to_i
trans = n.times.map { gets.to_i }

next_btn = 1
cnt = 0
ans = -1
(n + 1).times do
  if next_btn == 2
    ans = cnt
    break
  end

  cnt += 1
  next_btn = trans[next_btn - 1]
end

puts ans


Measured memory_bytes: 2996
"""
偶数：偶数＋偶数 or 奇数＋奇数
奇数：偶数＋奇数
"""

def the_number_of_even_pairs():
    # 入力
    N, M = map(int, input().split())
    # 初期処理
    list_N = [0] * N
    list_M = [1] * M
    even_pairs_count = 0
    # 判別処理
    # 偶数＋偶数
    for _ in range(N):
        even_pairs_count += len(list_N)-1
        list_N.pop(0)
    # 奇数＋奇数
    for _ in range(M):
        even_pairs_count += len(list_M)-1
        list_M.pop(0)
    # 結果
    return even_pairs_count

result = the_number_of_even_pairs()
print(result)

Measured memory_bytes: 8824
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

const int N = 1000001;

int a, b;
int p[N];
bool used[N];

main(){
  while(cin >> a >> b && (a | b)){
    fill(used, used+N, false);
    for(int i=1;;i++){
      if(!used[a]){
        used[a] = true;
        p[a] = i;
      }else{
        cout << p[a]-1 << ' ' << i - p[a] << endl;
        break;
      }
      //cout << "! " << a << ' ' << b << endl;
      if(a % b == 0){
        cout << i-1 << ' ' << 0 << endl;
        break;
      }
      a = a*10 % b;
    }
  }
  return 0;
}

Measured memory_bytes: 5748
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    i64 n, k;
    cin >> n >> k;
    vector<i64> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    sort(begin(h), end(h));
    i64 ans = 0;
    for (int i = 0; i < n - k; ++i) {
        ans += h[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
import math

class Triangle():

    def __init__(self, edge1, edge2, angle):
        self.edge1 = edge1
        self.edge2 = edge2
        self.angle = angle
        self.edge3 = math.sqrt(edge1 ** 2 + edge2 ** 2 - 2 * edge1 * edge2 * math.cos(math.radians(angle)))
        self.height = edge2 * math.sin(math.radians(angle))
        self.area = edge1 * self.height / 2

a, b, theta = [int(i) for i in input().split()]

triangle = Triangle(a, b, theta)

print(triangle.area)
print(triangle.edge1 + triangle.edge2 + triangle.edge3)
print(triangle.height)


Measured memory_bytes: 5724
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = list(map(int, input().split()))
    #a = [list(input().split()) for i in range(n)]
    #a = [int(input()) for i in range(n)]
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    x,y,a,b,c=map(int,input().split())
    p=sorted(list(map(int,input().split())), reverse=True)[:x]
    q=sorted(list(map(int,input().split())), reverse=True)[:y]
    r=sorted(list(map(int,input().split())), reverse=True)
    print(sum(sorted((p+q+r), reverse=True)[:x+y]))

if __name__ == '__main__':
    main()



Measured memory_bytes: 110188
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD  998244353 // 1000000007 // //100000000
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << " "; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}
ll lcm(ll a, ll b) {return (a/__gcd(a, b))*b; }

void solve(){
    string s;
    cin >> s;
    ll n = s.size(), k , ans = 0;
    cin >> k;
    if(n == 1) ANS(k/2);
    ll f = 0;
    rep(i, n-1) if(s[i] != s[i+1]) {f = 1; break;}
    if(!f) ANS((k*n)/2);
    ll l = 1;
    rep(i, n)
    {
        if(s[i] == s[i+1]) l++;
        else{
            ans += (l/2); l = 1;
        }
    }
    if(s[0] == s[n-1]){
        ll a = 0, b = 0;
        rep(i, n) {a++; if(s[i] != s[i+1]) break;}
        repr(i, n) {b++; if(s[i] != s[i-1]) break;}
        cout << ans*k - (k-1)*(a/2+b/2 - (a+b)/2);
    }
    else cout << ans*k;
}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3624
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(ll i=ini;i<(int)n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e8+7;


void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)
 
  
int main()
{
    int n,k;
    scf(n),scf(k);
    
    int a[n];
    
    rep(i,0,n)
    scf(a[i]);
    
    sort(a,a+n);
    
    int ctr=0;
    
    rep(i,0,k)
    ctr+=a[i];
    
    
    prin(ctr);
    
            
}

Measured memory_bytes: 3828
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int d;
  string s;
  cin >> s >> d;
  ll ans=0,dp[10005][2][105]={};
  cin >> s >> d;
  dp[0][0][0]=1;
  for(int i=0; i<s.size(); i++) {
    for(int j=0; j<2; j++) {
      for(int k=0; k<d; k++) {
        int lim=j?9:s[i]-'0';
        for(int l=0; l<=lim; l++) {
          (dp[i+1][j||l<lim][(k+l)%d]+=dp[i][j][k])%=MOD;
        }
      }
    }
  }
  for(int i=0; i<2; i++) {
    ans+=dp[s.size()][i][0];
    ans%=MOD;
  }
  ans--;
  //ansがMODの倍数の可能性もある　<-いや普通気づかないだろ...
  if(ans<0) {
    ans+=MOD;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 16640
n=int(input())
mat=[[0] * n for _ in range(n)]
for _ in range(n):
    adj=list(map(int, input().split()))
    i=adj[0]
    for j in adj[2:]:
        mat[i - 1][j - 1]=1
for m in mat:
    print(' '.join(map(str, m)))


Measured memory_bytes: 5676
import java.lang.*;
import java.io.*;
import java.util.*;

class Main{
	public static void main(String args[]) throws Exception{
		FScanner sc=new FScanner();
		int n=sc.readInt();
		if(n==1){
			System.out.println("Hello World");
		}else{
			int a=sc.readInt();
			int b=sc.readInt();
			System.out.println(a+b);
		}
	}
	
	static void solve(int cur, int nx, int en, int hld){}

	static void disp(int[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
	
	static void disp(String[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%s ",data[i]);
		}
			System.out.println();
	}
	
	static void disp(long[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
	
	static class FScanner{
		BufferedReader read=null;
		StringTokenizer tok=null;
		Scanner sc;
		FScanner() throws FileNotFoundException{
			sc=new Scanner(System.in);
		}
		boolean hasNextLine(){
			boolean has=true;
			if(!sc.hasNextLine()){
				has=false;
			}
			return has;
		}
		int readInt(){
			String buf=sc.nextLine();
			return Integer.parseInt(buf);
		}
		long readLong(){
			long i=Long.parseLong(sc.nextLine());
			return i;
		}
		int[] readIntL(){
			String[] buf=sc.nextLine().split(" ");
			int[] num=new int[buf.length];
			for(int i=0; i<buf.length; i++){
				num[i]=Integer.parseInt(buf[i]);
			}
			return num;
		}
		
		String readString(){
			return sc.nextLine();
		}
		String[] readStringL(String dlm){
			String[] s=sc.nextLine().split(dlm);
			return s;
		}
	}
}


Measured memory_bytes: 21972
<?php
while(($in = trim(fgets(STDIN)))!='0 0'){
	$dp=array(array());
	sscanf($in,"%d %d",$n,$s);
	for($i=0;$i<=10;$i++){
		for($j=0;$j<=1000;$j++){
		$dp[$i][$j]=0;
	}
 }
 $dp[0][0]=1;
	for($i=0;$i<=100;$i++){
		for($j=$n;$j>=0;$j--){
			for($m=0;$m+$i<=$s;$m++){
				$dp[$j+1][$m+$i]+=$dp[$j][$m];
			}
		}
	}
	print($dp[$n][$s]."\n");
}

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

#define ll long long
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;


int main() {
    int N;
    cin >> N;
    int a[1000000];
    for(int i=0;i<3*N;i++){
        cin >> a[i]; 
    }
    sort(a,a+3*N,greater<int>());
    ll sum =0;
    for (int j=0;j<N;j++){
        sum += a[2*j+1];
    }
   cout << sum << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
 
#define sd(mark) scanf("%d",&mark)
#define ss(mark) scanf("%s",&mark)
#define sl(mark) scanf("%lld",&mark)
#define debug(mark) printf("check%d\n",mark)
#define clr(mark) memset(mark,0,sizeof(mark))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ll long long
int a[210];
int main()
{
	int n,i;
	int ans=0;
	sd(n);
	for(i=0;i<2*n;++i)
		sd(a[i]);
	sort(a,a+2*n);
	for(i=0;i<2*n;i+=2)
		ans+=a[i];
	printf("%d\n",ans);
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



ll n,m;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n>>m;
    
    if (m<=2LL*n) {
	out(m/2);
    }

    ll ans = n;
    m -= 2LL*n;
    n = 0;
    ans += m/4;
    out(ans);
  

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

int main()
{
    int sx,sy,gx,gy;
    cin >> sx >> sy >> gx >> gy;

    int dx = gx - sx;
    int dy = gy - sy;

    for(int i = 0; i < dy; i++){
        cout << 'U';
    }
    for(int i = 0; i < dx; i++){
        cout << 'R';
    }
    for(int i = 0; i < dy; i++){
        cout << 'D';
    }
    for(int i = 0; i < dx; i++){
        cout << 'L';
    }

    cout << 'L';

    for(int i = 0; i <= dy; i++){
        cout << 'U';
    }
    for(int i = 0; i <= dx; i++){
        cout << 'R';
    }

    cout << 'D' << 'R';

    for(int i = 0; i <= dy; i++){
        cout << 'D';
    }
    for(int i = 0; i <= dx; i++){
        cout << 'L';
    }
    
    cout << 'U' << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
  char s[100000];
  scanf("%s",s);

  for(int i = 0;i < strlen(s)-1;i++){
    if(s[i] == s[i+1]){
      printf("%d %d\n",i+1,i+2);
      return 0;
    }
    if(i+2 < strlen(s) && s[i] == s[i+2]){
      printf("%d %d\n",i+1,i+3);
      return 0;
    }
  }

  printf("-1 -1\n");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main(void){
   int a,b,c,s=0,r=0;
   char ch;
   
   while(cin>>a>>ch>>b>>ch>>c){
       if(a*a + b*b == c*c){
           s++;
       }
       if(a == b){
           r++;
       }
   }
   cout<<s<<endl<<r<<endl;
   
   return 0;
}



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

int main(){
	int x,y,z;
	cin>>x>>y>>z;
	
	x-=z;
	int cnt=0;
	while(x-z-y>=0){
		x-=z+y;
		cnt++;
	}
	
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define mp make_pair
#define pb push_back
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

int main() {
	int N, M;
	cin >> N >> M;
	vector<ll> a(M);
	vector<ll> b(M);
	vector<ll> c(M);
	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--; b[i]--;
	}

	vector<ll> v(N, -LINF);
	v[0] = 0;
	for (int i = 0; i < N; i++) {
		for (int i = 0; i < M; i++) v[b[i]] = max(v[b[i]], v[a[i]] + c[i]);
	}
	ll ans1 = v[N-1];

	for (int i = 0; i < N; i++) {
		for (int i = 0; i < M; i++) v[b[i]] = max(v[b[i]], v[a[i]] + c[i]);
	}
	ll ans2 = v[N-1];

	if (ans1 == ans2) cout << ans1 << endl;
	else cout << "inf" << endl;
    return 0;
}


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

vertical = int(HW[0] / 2) + (HW[0] % 2)
horizontal = int(HW[1] / 2) + (HW[1] % 2)

if (HW[0] == 1 or HW[1] == 1):
    print(1)
else:
    pairV = 0
    secondV = 0
    if (HW[0] % 2 == 0):
        pairV = vertical * 2
    else:
        pairV = vertical * 2 - 1
    if (HW[1] % 2 == 0):
        print(pairV * int(HW[1] / 2))
    else:
        tmp = pairV * int(HW[1] / 2)
        tmp += vertical
        print(tmp)


Measured memory_bytes: 3064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
      System.out.println((A == B && B == C) ? "Yes" : "No");
	}
}


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

using namespace std;

typedef long long ll;

int arr[(int)1e5+10];

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

    int h, n;
    cin >> h >> n;

    int total = 0;
    for(int i=0; i<n; i++){
        cin >> arr[i];
        total+=arr[i];
    }

    if(h>total) cout << "No\n";
    else cout << "Yes\n";

    return 0;
}

Measured memory_bytes: 640
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

func main() {
	n := 5
	f := make(sortArray, n)
	for i := 0; i < n; i++ {
		a := readInt()
		f[i].x = a
		if a%10 == 0 {
			f[i].r = 10
		} else {
			f[i].r = a % 10
		}
	}

	sort.Sort(f)

	ans := 0
	for i := range f {
		a := f[n-1-i]
		if i == n-1 {
			ans += a.x
		} else if a.r == 10 {
			ans += a.x
		} else {
			ans += a.x - a.r + 10
		}
	}

	fmt.Println(ans)
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
	r int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].r < s[j].r }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

class Main{
    private static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    private static final PrintWriter out = new PrintWriter(System.out);
    public static void main(String[] Args) throws IOException{
        final int[] alph = new int[26];
        String in;
        while( (in = br.readLine())!=null){
            for(int i = 0; i<in.length(); i++){
                if(Character.isUpperCase(in.charAt(i))) alph[in.charAt(i)-'A']++;
                if(Character.isLowerCase(in.charAt(i))) alph[in.charAt(i)-'a']++;
            }
        }
        for(int i = 0; i<26; i++){
            out.print((char) ('a'+i));
            out.print(" : ");
            out.println(alph[i]);
        }
        out.flush();
    }
}

Measured memory_bytes: 24248
#include <bits/stdc++.h> 
using namespace std; 
int main()
{ 
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    string A;cin>>A;
    int N=A.size();
    if(N%2!=0)
    {
        cout<<"No";
        return 0;    
    }
    for(int i=0;i<N-1;i+=2)
    {
        if(A[i]!='h' || A[i+1]!='i')
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
}

Measured memory_bytes: 256
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
ans=1000000000
for i in range(n):
    if abs(a-(t-(h[i]*0.006)))<ans:
        ans=abs(a-(t-(h[i]*0.006)))
        ind=i+1
print(ind)


Measured memory_bytes: 3060
import std.stdio;
import std.algorithm;
import std.string;
import std.functional;
import std.array;
import std.conv;
import std.math;
import std.typecons;
import std.regex;
import std.range;

void main(){

    while(true){
	auto s = readln().split().to!(double[]);
	if(s[0] == 0 && s[1] == 0 && s[2] == 0) break;
	int r = to!int( sqrt( s[1]*s[1] + s[2]*s[2] )/2.0 );
	int n = readln().chomp().to!int;
	for(int i=0;i<n;i++){
	    if( r < readln().chomp().to!int) writeln("OK");
	    else writeln("NA");
	}
    }

}

Measured memory_bytes: 2448
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int32_t main()
{
	//freopen("input.txt", "r", stdin);
	IOS;
	
	int n; cin >> n;
	vector<int> a(n);
	for(auto &x: a) cin >> x;

	const int MOD = 1e9 + 7;

	int sum = 0;
	for(auto x: a) {
		sum = (sum + x)%MOD;
	}

	int ans = 0, prev = 0;
	for(auto x: a) {
		prev = (prev + x)%MOD;
		ans = (ans + (x * (sum - prev + MOD))%MOD)%MOD;
	}

	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 4740
#include <iostream>

using namespace std;

int main()
{
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;

    int maxX,minX,maxY,minY;
    maxX = x + r;
    minX = x - r;
    maxY = y + r;
    minY = y - r;
    
    if(maxX > W || minX < 0 || maxY > H || minY < 0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
from collections import deque
def MI(): return map(int, input().split())
INF=float('inf')
def bfs():
  que=deque()
  que.append((sx,sy))
  dist=[[INF] *W for _ in range(H)]
  dist[sx][sy]=0
  dx=[1,0,-1,0]
  dy=[0,1,0,-1]
  while que:
    x,y=que.popleft()
    if x==gx and y==gy:
      break
    for i in range(4):
      nx=x+dx[i]
      ny=y+dy[i]
      if 0<=nx<H and 0<=ny<W:
        if Map[nx][ny]!='#':
          if dist[nx][ny]==INF:
            dist[nx][ny]=dist[x][y]+1
            que.append((nx,ny))
  return dist[gx][gy]
H,W=MI()
Map=[list(input()) for i in range(H)]
sx,sy=0,0
gx,gy=H-1,W-1
white=0
for i in range(H):
  for j in range(W):
    if Map[i][j]=='.':
      white+=1
res=bfs()
if 0<res<INF:
  print(white-res-1)
else:
  print(-1)

Measured memory_bytes: 9516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    double q, h, s, d;
    int n;
    cin >> q >> h >> s >> d >> n;
    int mn = min({q * 4, h * 2, s});
    int mn2 = min({q * 8, h * 4, s * 2, d});
    int ans = n / 2 * mn2 + n % 2 * mn;
    cout << ans << "\n";
}

Measured memory_bytes: 3696
#include <stdio.h>

int main (void){
int N,K;
  scanf("%d%d",&N,&K);
  int x=1;
  for(int i=0;i<N;i++){
  if(2*x>=x+K){
  x+=K;
  }else{
  x*=2;
  }
 }
  printf("%d",x);
  
  
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using Int = long long;

template< typename T >
struct Dinic
{
  struct edge
  {
    int to;
    T cap;
    int rev;
  };

  const T INF;
  vector< vector< edge > > graph;
  vector< T > min_cost;
  vector< int > iter;

  Dinic(int n) : INF(numeric_limits< T >::max())
  {
    graph.resize(n);
  }

  void add_edge(int from, int to, T cap)
  {
    graph[from].push_back((edge) {to, cap, (int) graph[to].size()});
    graph[to].push_back((edge) {from, 0, (int) graph[from].size() - 1});
  }

  bool bfs(int s, int t)
  {
    min_cost.assign(graph.size(), -1);
    queue< int > que;
    min_cost[s] = 0;
    que.push(s);
    while(!que.empty()) {
      int p = que.front();
      que.pop();
      for(auto &e : graph[p]) {
        if(e.cap > 0 && min_cost[e.to] == -1) {
          min_cost[e.to] = min_cost[p] + 1;
          que.push(e.to);
        }
      }
    }
    return (min_cost[t] != -1);
  }

  T dfs(int idx, const int t, T flow)
  {
    if(idx == t) return (flow);
    for(int &i = iter[idx]; i < graph[idx].size(); i++) {
      edge &e = graph[idx][i];
      if(e.cap > 0 && min_cost[idx] < min_cost[e.to]) {
        T d = dfs(e.to, t, min(flow, e.cap));
        if(d > 0) {
          e.cap -= d;
          graph[e.to][e.rev].cap += d;
          return (d);
        }
      }
    }
    return (0);
  }

  T max_flow(int s, int t)
  {
    T flow = 0;
    while(bfs(s, t)) {
      iter.assign(graph.size(), 0);
      T f = 0;
      while((f = dfs(s, t, INF)) > 0) {
        flow += f;
      }
    }
    return (flow);
  }
};

int main()
{
    int N; cin >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    int S = N, T = N+1;
    Dinic<Int> dinic(N+2);
    Int sum = 0;
    for (int i = 0; i < N; i++) {
        dinic.add_edge(S, i, (A[i] <= 0 ? -A[i] : 0));
        dinic.add_edge(i, T, (A[i] >= 0 ?  A[i] : 0));
        if (A[i] > 0) sum += A[i];
    }
    const Int INF = 1e12;
    for (int i = 0; i < N; i++) {
        int n = i + 1;
        for (int m = n + n; m <= N; m += n) {
            dinic.add_edge(n-1, m-1, INF);
        }
    }
    cout << sum - dinic.max_flow(S, T) << '\n';
    return 0;
}


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

int main() {
	string s;
	cin >> s;
	int a = 0 , b = 0 , l = s.length() ;
	for(int i = 0 ; i < l ; i++)
	{
		if(s[i]=='0')
			a++;
		else
			b++;
	}
	cout << 2*min(a,b) ;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>	
#define pb push_back
typedef long long ll;
const int inf = 2e9;
using namespace std;


ll C[100][100];

ll binomic(int n, int r){
	if(C[n][r]!=0) return C[n][r];
	if(n==r || r==0) return 1;
	return C[n][r] = binomic(n-1,r-1)+binomic(n-1,r);
}

int buscar(int A[],int l, int r, int dato){
	if(l>r) return -1;
	int mid = (l+r)/2;
	if(A[mid]==dato) return mid;
	if(A[mid]>dato) return buscar(A,l,mid-1,dato);
	return buscar(A,mid+1,r,dato);
}

bool isPossibleSum(int sum,int n,int A[]){
	if(n==0 && sum!=0) return false;
	if(sum==0) return true;
	if(A[n-1]>sum) return isPossibleSum(sum,n-1,A);
	return isPossibleSum(sum-A[n-1],n-1,A) || isPossibleSum(sum,n-1,A);
}


char P[100005];

int solve(int n){
	if(n==0) return 1;
	if(n%2==0 || P[n]!=P[n/2]) return 1+solve(n-1);
	int i=n/2;
	while(P[i]==P[i+n/2+1] && i!=-1)i--;
	if(i==-1) return 1 + solve(n/2);
	return n/2-i + solve(n/2+i+1);
}
/*
int A[102], dp[10004];

int solve(int n,int v){
	if(v==0)return 0;
	if(dp[v]!=0) return dp[v];
	int ans = inf;
	for(int i = 0; i < n ; ++i)
	{
		if(A[i]<=v) ans = min(ans,solve(n,v-A[i])+1);
		else return dp[v] = ans;
	}
	return dp[v] = ans;
}
*/
bool U[30];
int main(){
	
	char S[1000];
	scanf("%s",S);
	int l=strlen(S);

	for (int i = 0; i < l; ++i) U[S[i]-'a'] = true;

	for (int i = 0; i < 26; ++i)
	{
		if(!U[i]){
			printf("%s",S);
			printf("%c\n",(i+'a'));
			return 0;
		}
	}


	if(l==26){
		int mi=inf;
		for (int i = l-2; i>=0; --i)
		{	

			for (int k = i+1; k < 26 ; ++k)
			{
				if(S[i]-'a'<S[k]-'a'){
					mi = min(mi,S[k]-'a');
				}
			}

			if(mi!=inf){		
				for (int j = 0; j < i; ++j)
				{
						printf("%c",S[j]);
				}
				printf("%c\n",mi+'a');
				return 0;
			}

		}
		printf("-1\n");
		return 0;
	}

	


	return 0;
}	

Measured memory_bytes: 256
import java.util.*; 


public class Main
 {
	public static void main (String[] args)
	 {
	    Scanner in = new Scanner(System.in);
	    int n = in.nextInt();
	    in.nextLine();
	    String[] A = new String[n];
	    
	    
	    for(int i=0;i<n;i++) {
	    	A[i] = in.nextLine();
	    	
	    }
	    
	    for(int i=0;i<n;i++) {
	    	char[] stringArray = A[i].toCharArray();
	    	Arrays.sort(stringArray);
	    	A[i] = new String(stringArray);
	    }
	    
	    Arrays.sort(A);
	    long ans = 0;
	    
	    long count = 1;
	    String current = "";
	    for(int i=0;i<n;i++) {
	    	if(!current.equals(A[i])) {
	    		ans += count*(count-1)/2;
	    		count = 1;
	    		
	    		
	    		
	    	}
	    	else {
	    		count++;
	    	}
	    	current = A[i];
	    	
	    }
	    ans+= count*(count-1)/2;
	   
	    System.out.println(ans);
	 }
	
	
	
	
	
	
	 

}





Measured memory_bytes: 99308
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define alll(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define endl '\n'

int main()
{
    int n;
    cin>>n;
    cout<<n/2*(n-n/2)<<endl;
}

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

using namespace std;
typedef long long ll;
#define int ll

template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

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

    int K, N;
    cin >> K >> N;
    vector<int> A(N);
    REP(i, N) { cin >> A[i]; }
    int ans = LLINF;
    for(int i = 0; i < N - 1; ++i) {
        chmin(ans, K - abs(A[i + 1] - A[i]));
    }
    chmin(ans, A[N-1] - A[0]);
    printf("%lld\n", ans);

    return 0;
}



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

class Program {
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return Console.ReadLine().Split(); }

    static void Main() {
        var t = Console.ReadLine();
        int n = 0, w = 0, s = 0, e = 0;
        foreach (var c in t) {
            switch (c) {
                case 'N': n++; break;
                case 'W': w++; break;
                case 'S': s++; break;
                case 'E': e++; break;
            }
        }

        if ((n + s > 0 && n * s == 0) || (w + e > 0 && w * e == 0))
            Console.WriteLine("No");
        else
            Console.WriteLine("Yes");
    }
}

Measured memory_bytes: 2648
(declaim (optimize (speed 3) (debug 0) (safety 0)))
(let ((k (read))
      (s (read)))

  (declare (type fixnum k))
  (declare (type fixnum s))

  (format t "~A~%"
          (loop for i from 0 to k
                sum (loop for j from 0 to k
                          count (and (>= (the fixnum (- s i j)) 0) (<= (the fixnum (- s i j)) k))))))


Measured memory_bytes: 24420
import math

d = list(map(int,input().split(' ')))
N = d[0]
X = d[1]
min_m = 0

for i in range(N):
	mi = int(input())
	X = X - mi
	if min_m == 0 or min_m > mi:
		min_m = mi

print(N + math.floor(X/min_m))

Measured memory_bytes: 3064
n,k=map(int,input().split())
a=list(map(int,input().split()))
d={}
for x in a:
     if x in d:
          d[x]+=1
     else:
          d[x]=1
l=list(d.values())
l.sort()
if k >= len(l):
     print(0)
else:
     print(sum(l[:-k]))

Measured memory_bytes: 32188
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <map>
#include <queue>
#include <string>
using namespace std;

string s;

int main(){
	while(cin>>s){
		int cur=0;
		while(cur<s.size()){
			if(s[cur]!='@'){cout<<s[cur];cur++;}
			else {
				for(int i=0;i<s[cur+1]-'0';i++)cout<<s[cur+2];
				cur+=3;
			}
		}
		cout<<endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define lld long long int
#define vec vector<lld>
#define pll pair<lld,lld>
#define pb push_back
#define ss second
#define ff first
#define mp make_pair
#define mod 1000000007
#define answer(x) cout<<endl<<"answer : "<<x<<endl<<endl;
#define op(x) cout<<x<<endl;
#define maxn 100005
#define messi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main() {messi lld t=1;//cin>>t;
    while(t--)
    {
        lld n=0,m=0,k=0,i=0,j=0,p=0,q=0,x=0,y=0,z=0,ans=0,cnt=0,l=0,r=0,mid=0,lo=0,hi=0;string s;bool flag=false;
        cin>>n; lld a[n]; for(i=0;i<n;i++) cin>>a[i];
        for(i=0;i<n;i++)
        {
            for(j=i+1;j<n;j++)
            {
                for(k=j+1;k<n;k++)
                {
                    if(((a[i]+a[j])>a[k]) && ((a[i]+a[k])>a[j]) && ((a[j]+a[k])>a[i]) && a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i])
                        cnt++;
                }
            }
        }
        cout<<cnt<<endl;

    }
	return 0;
}
/*  CODED BY:-
 ________________________________________
|            __        __                |
|  /\   /\  |__)  /\  |  \ |__| \ /  /\  |
| /~~\ /~~\ |  \ /~~\ |__/ |  |  |  /~~\ |
|________________________________________|

*/


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < N; i++)
using namespace std;
int main()
{
    vector<int> A(9), B(9), count(9);
    A[0] = 1;
    B[0] = 399;
    A[8] = 3200;
    B[8] = 4800;

    for (int i = 1; i < 8; i++)
    {
        A[i] = 400 * i;
        B[i] = B[i - 1] + 400;
    }
    rep(i, 9)
    {
        count[i] = 0;
    }
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N)
    {
        cin >> a[i];
    }
    rep(j, N)
    {
        rep(i, 9)
        {
            if (A[i] <= a[j] && a[j] <= B[i])
            {
                count[i]++;
            }
        }
    }
    int min = 0;
    rep(i, 8)
    {
        if (count[i] != 0)
        {
            min++;
        }
    }
    if (a[0] >= 3200 && N == 1)
    {
        cout << 1 << " " << 1 << endl;
    }
    else if (count[8] == N)
    {
        cout << 1 << " " << count[8] << endl;
    }
    else if (count[8] != 0)
    {
        cout << min << " " << min + count[8] << endl;
    }

    else
    {
        cout << min << " " << min << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t N, K;
    cin >> N >> K;
    if (K % 2 == 1) {
        int64_t a = N / K;
        cout << a * a * a << endl;
    }
    else {
        int64_t a = N / K, b = (N + K / 2) / K;
        cout << a * a * a + b * b * b << endl;

    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0,(i##_len)=(n);(i)<(i##_len);(i)++)
#define rep2(i,a,b) for(ll (i)=(a),(i##_len)=(b);(i)<=(i##_len);(i++))
#define rrep(i,n) ll(i)=(n);ll now=-1;while((i)--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)<<"\n"
#define vll vector<ll>
#define pb push_back
using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {}
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;}
template<class T> T abs(T x){return max(x,-x);}
template<class T> T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> T lcm(T m,T n) {return m*n/gcd(m,n);}
template<class T> T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm<T>(r,v.at(i));return r;}
template<class T> T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> T nCr(T n,T k){return factorial<T>(n)/(factorial<T>(k)*factorial<T>(n-k));}
template<class T> T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

void solve(ll N, ll x, vector<ll> a){
    sort(all(a));
    rep(i, N) {
        if (x < a.at(i)) {
            cout << i << "\n";
            return;
        }
        x -= a.at(i);
    }
    if (x == 0) cout << N << "\n";
    else cout << N - 1 << "\n";
}

int main() {
    ll N;
    ignore_ret(scanf("%lld",&N));
    ll x;
    ignore_ret(scanf("%lld",&x));
    vector<ll> a(N);
    for(int i = 0 ; i < N ; i++){
        ignore_ret(scanf("%lld",&a[i]));
    }
    solve(N, x, move(a));
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    int n, k;
    cin >> n >> k;
    vector<double> v(n+1, 0);
    double p;
    for (int i = 0; i < n; ++i) {
        cin >> p;
        v[i+1] = 1 / p / 2 * p * (p + 1);
    }

for (int i = 0; i < n; ++i){
        v[i+1] += v[i];
    }

    double res = 0;
    for (int i = 0; i <= n - k; ++i) {
        res = max(res, v[i+k] - v[i]);
    }
    cout << fixed << setprecision(12) << res << endl;
}

Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))

dp=[[0]*2 for _ in range (n+1)]
dp[0][0]=0
dp[0][1]=-float('inf')

for i in range(n):
  dp[i+1][0]=max(dp[i][0]+a[i], dp[i][1]-a[i])
  dp[i+1][1]=max(dp[i][0]-a[i], dp[i][1]+a[i])

print(dp[n][0])


Measured memory_bytes: 31036
#include <iostream>
#include <array>
#include <algorithm>

int main(void)
{
    std::array<int, 3> ary;
    std::cin >> ary[0] >> ary[1] >> ary[2];

    std::sort(ary.begin(), ary.end());
    std::cout << ary[0] << " " << ary[1] << " " << ary[2] << std::endl;

    return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
int main()
{
  string t = "CODEFESTIVAL2016";
  string s;
  cin >> s;
  int cnt = 0;
  rep(i,s.size()){
    if(t[i]!=s[i]) cnt++;
  }
  cout << cnt << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define double long double
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n,k;cin>>n>>k;
    ll cnt=0;
    rep(i,n){
        ll h;cin>>h;
        cnt+=(h>=k);
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
#define MX 100000
#define mod
#define ll long long
const double pi = acos(-1.0);

using namespace std;

int main()
{
	char a[110000];
	int len;
	cin>>a;
	len=strlen(a);
	for(int i=0;i<len;i=i+2){
		cout<<a[i];
	}
}




Measured memory_bytes: 384