akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(false),cin.tie(nullptr);
#define task "random"
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))

const int N=310;

int n,m,l;
ii f[N][N];
vector<ii> ad[N];

main(){
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);

    n=in,m=in;
    cout<<max(n-m*2,0ll);

    return 0;

    n=in,m=in,l=in;
    forinc(i,1,m){
        int u=in,v=in,c=in;
        if(c>l) continue;
        ad[u].pb({v,c});
        ad[v].pb({u,c});
    }

    forinc(i,1,n)
        forinc(j,1,n)
            f[i][j]=i==j?ii(0,-l):ii(n+1,0);
    forinc(i,1,n){
        using w=tuple<int,int,int>;
        priority_queue<w,vector<w>,greater<w>> q;
        q.push(mt(0,-l,i));
        int c,g,u;
        while(q.size()){
            tie(c,g,u)=q.top(); q.pop();
            //cout<<f[i][u].fi<<" "<<f[i][u].se<<"\n";
            if(f[i][u]<ii(c,g)) continue;
            //cerr<<c<<" "<<g<<" "<<u<<"\n";
            forv(v,ad[u]){
                int C,G;
                if(-g>=v.se) C=c,G=-g-v.se;
                else C=c+1,G=l-v.se;
                if(f[i][v.fi] > ii(C,-G)){
                    f[i][v.fi]=ii(C,-G);
                    q.push(mt(C,-G,v.fi));
                }
            }
        }
        //cout<<f[5][2].fi;
        ///return 0;
        //return 0;
    }

    forinc(i,1,in){
        int u=in,v=in;
        cout<<(f[u][v].fi>n?-1:f[u][v].fi)<<"\n";
    }
}


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

int main() {
	int a, b;
	cin >> a >> b;
	int ans = max(a, b);
	if (a > b) {
		if (a - 1 > b) {
			ans += a - 1;
		} else {
			ans += b;
		}
	} else {
		if (b - 1 > a) {
			ans += b - 1;
		} else {
			ans += a;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>

template<class T>
struct binary_serch_tree{
  struct tree{
    T id;
    tree* left;
    tree* right;
    tree* parent;
  };
  tree* root;
  tree original;
  tree* null=&original;
  binary_serch_tree(){
    this->root=this->null;
    root->right=this->null;
    root->left=this->null;
  }

  void set_tree(tree* tr,tree* root){
    tree* null=this->null;
    tree* left=root->left;
    tree* right=root->right;
    if(root->id>tr->id){
      if(left==null){
        root->left=tr;
        tr->parent=root;
        tr->left=null;
        tr->right=null;
      }else{
        set_tree(tr,left);
      }
    }else{
      if(right==null){
        root->right=tr;
        tr->parent=root;
        tr->left=null;
        tr->right=null;
      }else{
        set_tree(tr,right);
      }
    }
  }

  void insert(T a){
    tree* tr=new tree;
    tr->id=a;
    if(this->root==this->null){
      this->root=tr;
      tr->left=this->null;
      tr->right=this->null;
      tr->parent=this->null;
    }else{
      set_tree(tr,this->root);
    }
  }
  void go_pre(tree* root){
    std::cout<<" "<<root->id;
    tree* left=root->left;
    tree* right=root->right;
    tree* null=this->null;
    if(left==null&&right==null){
      //do nothing
    }else if(left==null){
      go_pre(right);
    }else if(right==null){
      go_pre(left);
    }else{
      go_pre(left);
      go_pre(right);
    }
  }
  void print_pre(){
    go_pre(this->root);
  }
  void go_in(tree *root){
    tree* left=root->left;
    tree* right=root->right;
    tree* null=this->null;
    if(left==null&&right==null){
      std::cout<<" "<<root->id;
    }else if(left==null){
      std::cout<<" "<<root->id;
      go_in(right);
    }else if(right==null){
      go_in(left);
      std::cout<<" "<<root->id;
    }else{
      go_in(left);
      std::cout<<" "<<root->id;
      go_in(right);
    }
  }
  void print_in(){
    go_in(this->root);
  }

  int check_num(T a,int* check,tree* root){
    if(root->id==a){
      *check=1;
      return 0;
    }else{
      if(root->id>a&&root->left!=this->null){
        check_num(a,check,root->left);
      }else if(root->id<a&&root->right!=this->null){
        check_num(a,check,root->right);
      }else{
        return 0;
      }
    }
    return 0;
  }

  void find(T a){
    int* check;
    int c=0;
    check=&c;
    check_num(a,check,this->root);
    if(*check==0){
      std::cout<<"no"<<std::endl;
    }else{
      std::cout<<"yes"<<std::endl;
    }
  }

};



int main(){
  int n;
  std::cin>>n;
  binary_serch_tree<int> T;
  for(int i=0;i<n;i++){
    std::string s;
    std::cin>>s;
    if(s=="insert"){
      int a;
      std::cin>>a;
      T.insert(a);
    }else if(s=="find"){
      int a;
      std::cin>>a;
      T.find(a);
    }else{
      T.print_in();
      std::cout<<std::endl;
      T.print_pre();
      std::cout<<std::endl;
    }
  }
}



Measured memory_bytes: 21768
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

int main() {
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int cnt = 0;
	rep(i, a+1) {
		rep(j, b+1) {
			rep(k, c+1) {
				if (x == 500 * i + 100 * j + 50 * k) {
					cnt++;
				}
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long LL;

const int MaxN = 2e5;
int n, m, a[MaxN + 5], b[MaxN + 5];
map <int, int> cnt;

int main()
{
	while (~scanf("%d", &n)) {
		cnt.clear();
		int x;
		for (int i = 1; i <= n; i++) scanf("%d", &x), cnt[x]++;
		bool flag = true;
		scanf("%d", &m);
		for (int i = 1; i <= m; i++) {
			scanf("%d", &x);
			if (cnt[x] == 0) flag = false; else cnt[x]--;
		}
		if (flag) printf("YES\n"); else printf("NO\n");
	}
	return 0;
}

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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;

        static void SolveA()
        {
            int n = ReadAndParseInt();
            var a = ReadAndParseIntArr();
            StringBuilder sb = new StringBuilder();
            if( n % 2 == 0)
            {
                for (int i = n; i >= 2; i -= 2)
                {
                    sb.Append(a[i-1].ToString() + " ");
                }
                for (int i = 1; i <= n - 1; i += 2)
                {
                    sb.Append(a[i - 1].ToString() + " ");
                }
                
            }
            else
            {
                for (int i = n; i >= 1; i -= 2)
                {
                    sb.Append(a[i - 1].ToString() + " ");
                }
                for (int i = 2; i <= n-1; i += 2)
                {
                    sb.Append(a[i - 1].ToString() + " ");
                }

            }
            sb.Remove(sb.Length - 1, 1);
            Console.WriteLine(sb.ToString());

        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

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

  while(true) {
    int n;
    cin >> n;
    if(!n) break;
    vector<string> s(n);
    REP(i, n) cin >> s[i];

    // 座圧しておく
    vector<char> v;
    REP(i, n) REP(j, s[i].size()) v.PB(s[i][j]);
    sort(ALL(v)); v.erase(unique(ALL(v)), v.end());
    REP(i, n) REP(j, s[i].size()) s[i][j] = lower_bound(ALL(v), s[i][j]) - v.begin() + 'A';

    // leading-zero対策
    vector<bool> fro(n, false);
    REP(i, n) if(s[i].size() >= 2) fro[s[i][0]-'A'] = true;

    // 係数を求める
    VI a(15, 0);
    REP(i, n) {
      for(int j=s[i].size()-1, tmp=1; j>=0; --j, tmp*=10) {
        if(i == n-1) a[s[i][j]-'A'] -= tmp;
        else a[s[i][j]-'A'] += tmp;
      }
    }

    map<PII, int> mp1, mp2;
    int m = v.size(), m2 = m/2;

    function<void(int,int,int)> dfs1 = [&](int x, int sum, int used) {
      if(x == m2) {mp1[{sum, used}]++; return;}
      REP(i, 10) {
        // leading-zeroとかすでに使ってる数は使えない
        if(fro[x] && i==0) continue;
        if(used&1<<i) continue;
        dfs1(x+1, sum+i*a[x], used | 1<<i);
      }
    };

    function<void(int,int,int)> dfs2 = [&](int x, int sum, int used) {
      if(x == m) {mp2[{sum, used}]++; return;}
      REP(i, 10) {
        if(fro[x] && i==0) continue;
        if(used&1<<i) continue;
        dfs2(x+1, sum+i*a[x], used | 1<<i);
      }
    };

    // 列挙
    dfs1(0, 0, 0);
    dfs2(m2, 0, 0);

    vector<pair<PII, int>> vec1(ALL(mp1)), vec2(ALL(mp2));

    for(auto &i: vec2) i.first.first *= -1;

    // 尺取りをする
    int ans = 0;
    int l = 0, r = vec2.size()-1;
    for(;l<vec1.size();) {
      while(r > 0 && vec1[l].first.first > vec2[r].first.first) r--;
      int val1 = vec1[l].first.first, val2 = vec2[r].first.first;
      // 合計が0にならないならcontinue
      if(val1 != val2) {
        while(l < vec1.size() && vec1[l].first.first==val1) l++;
        continue;
      }
      // 合計が0になるような組み合わせを全て見て使ってる数が被っていなければ答えにプラス
      for(int i=l; i<vec1.size() && vec1[i].first.first==val1; ++i) {
        for(int j=r; j>=0 && vec2[j].first.first==val2; --j) {
          if((vec1[i].first.second&vec2[j].first.second) == 0) {
            ans += vec1[i].second * vec2[j].second;
          }
        }
      }
      while(l < vec1.size() && vec1[l].first.first==val1) l++;
    }
    cout << ans << endl;
  }

  return 0;
}



Measured memory_bytes: 7808
H,W,D = map(int,input().split())
A = [[-1,-1] for _ in range(H*W)]
for i in range(H):
    t = [int(x)-1 for x in input().split()]
    for j in range(W):
        A[t[j]] = [i,j]    
        
Q = int(input())
LR = [[int(i) for i in input().split()] for _ in range(Q)]

M = []     
for i in range(H*W):
    if i<D:
        M.append(0)    
    else:
        M.append(M[i-D]+abs(A[i][0]-A[i-D][0])+abs(A[i][1]-A[i-D][1]))        
        
for L,R in LR:
    print(M[R-1]-M[L-1])        

Measured memory_bytes: 89068
N = int(input())
T = []
for i in range(5):
    T.append(int(input()))
k = 0
for i in range(5):
    if N % T[i] == 0:
        k = max(k, N//T[i])
    else:
        k = max(k, N//T[i] + 1)
print(4 + k)

Measured memory_bytes: 61888
#include <stdio.h>

int main() {
    int n, k, number = 1;
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++) {
        number = number * 2 < number + k ? number * 2 : number + k;
    }
    printf("%d\n", number);
    return 0;
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#define re register
using namespace std;
#define gc getchar
#define int long long
inline int read(){
	int t=0,f=0;
	char v=gc();
	while(v<'0')f|=(v=='-'),v=gc();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=gc();
	return f?-t:t;
}
int n,a[200002],b[200002],ans,m;
signed main(){
	n=read();m=read();
	for(re int i=1;i<=n;++i)a[i]=read(),b[i]=read();
	for(re int i=1;i<=n;++i){
		if(a[i]*a[i]+b[i]*b[i]<=m*m)++ans;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 6884
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))


n,q = readints()
s = readstr()
td = [readstrs() for i in range(q)]

l = -1
r = n
while l+1<r:
    m = (l+r)//2
    now = m
    for t,d in td:
        if s[now] == t:
            if d=='L':
                now -=1
            else:
                now += 1
            if now<0 or now>=n:
                break
    if now <0:
        l = m
    else:
        r = m
left = l

l = -1
r = n
while l+1<r:
    m = (l+r)//2
    now = m
    for t,d in td:
        if s[now] == t:
            if d=='L':
                now -=1
            else:
                now += 1
            if now<0 or now>=n:
                break
    if now >= n:
        r = m
    else:
        l = m
right = r

print(right-1-left)



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

int m, w;
int bm[12];
int bw[12];

int dp[13][1 << 12];

int calc(int a, int b)
{
	return abs(a - b) * (abs(a - b) - 30) * (abs(a - b) - 30);
}

void solve()
{
	memset(dp, 0, sizeof(dp));
	
	for (int i = 0; i < m; i++){
		for (int j = 0; j < (1 << w); j++){
			for (int k = 0; k < w; k++){
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
				
				int x = 1 << k;
				if (j & x) continue;
				
				int &next = dp[i + 1][j | x];
				next = max(next, dp[i][j] + calc(bm[i], bw[k]));
			}
		}
	}
	
	int res = 0;
	for (int i = 0; i < (1 << w); i++){
		res = max(res, dp[m][i]);
	}
	printf("%d\n", res);
}

int main()
{
	while (scanf("%d %d", &m, &w), m){
		for (int i = 0; i < m; i++){
			scanf("%d", &bm[i]);
		}
		for (int i = 0; i < w; i++){
			scanf("%d", &bw[i]);
		}
		solve();
	}
}

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

int main() {
  int a, b;
  cin >> a >> b;
  cout << max(a-b,max(a*b,a+b));
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
using namespace std;
int main(void){
    // Your code here!
    long long int n,k;
    cin >> n >> k;
    long long int a[n];
    long long int ans = 0;
    for(int i=0;i<n;i++)cin >> a[i];
    sort(a,a+n);
    reverse(a,a+n);
    for(int i=k;i<n;i++)ans+= a[i];
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<map>
#include<string>
#include<iostream>
#include<vector>


using namespace std;

int main(void){
    int N,Q;
    int l,r;
    string S;
    vector<int> count;


    int head=0;
    int tail=0;

    cin>>N>>Q;
    cin>>S;

    int count_array[S.length()];
    count_array[0]=0;
    for(int i=1;i<S.length();i++){
        if(S[i]=='C'&&S[i-1]=='A'){
            count_array[i] =count_array[i-1]+1;
        }else{
            count_array[i] = count_array[i-1];
        }
    }
    for(int i=0;i<Q;i++){
        cin>>l>>r;
        cout<<count_array[r-1]-count_array[l-1]<<endl;
    }
    return 0;

}


Measured memory_bytes: 1408
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	vs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&vs[i])
	}

	ans := 0
	lim := min(n, k)
	for a := 0; a <= lim; a++ {
		for b := 0; b <= lim-a; b++ {
			s := 0
			vv := make([]int, 0)
			for i := 0; i < a; i++ {
				v := vs[i]
				vv = append(vv, v)
				s += v
			}
			for i := 0; i < b; i++ {
				v := vs[n-i-1]
				vv = append(vv, v)
				s += v
			}
			sort.Ints(vv)

			for i := 0; i < k-(a+b); i++ {
				if i < len(vv)-1 && vv[i] < 0 {
					s -= vv[i]
				}
			}
			ans = max(ans, s)
		}
	}

	fmt.Println(ans)
}

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
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  ll N;
  scanf("%lld", &N);
  ll ans = 0;

  for (ll i = 1; i <= N; i++) {
    ll cnt = N / i;

    ll plus = (i + (i * cnt)) * cnt / 2;
    // cout << i << " " << plus << endl;
    ans += plus;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int ans=0;
  for(int i;i<N-1;i++){
   if(S.at(i)!=S.at(i+1)){
   ans=ans+1;
   }
  }
  cout<<ans+1<<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
const LL MOD = 998244353;
const double PI = 2 * acos(0);
int cnt[180];

int main() {
	int X;
	scanf("%d", &X);
	if (360 % X == 0) {
		cout << 360 / X << "\n";
		return 0;
	}
	cnt[0]++;
	int sudut = 360 - X, ans = 1;
	while (1) {
		ans++;
		if (sudut >= 180) cnt[sudut - 180]--;
		else cnt[sudut]++;
		sudut -= X;
		if (sudut < 0) sudut += 360;
		bool cek = 1;
		for (int i = 0; i < 180; i++) if (cnt[i] != 0) cek = 0;
		if (cek) {
			printf("%d\n", ans);
			return 0;
		}
	}
}

Measured memory_bytes: 3732
import sys

n,k,q = list(map(int,input().split()))
a = []

for _ in range(q):
    a.append(int(input()))

#n人の人がk-qポイント持つ
b = [k-q] * n

#正解者に1点ずつ足す
for i in range(len(a)):
    b[a[i]-1] += 1

for i in range(len(b)):
    if b[i] > 0:
        print("Yes")
    else:
        print("No")

    






Measured memory_bytes: 10472
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const ll MOD=998244353;
ll ans[400010],dif[400010];

int main(){
  ll n,k;
  cin>>n>>k;
  ll l[k],r[k];
  for(int i=0;i<k;i++)cin>>l[i]>>r[i];
  ans[0]=1;dif[1]=-1;
  for(int i=0;i<n;i++){
    for(int j=0;j<k;j++){
      dif[i+l[j]]+=ans[i];
      dif[i+l[j]]%=MOD;
      dif[i+r[j]+1]-=ans[i];
      dif[i+r[j]+1]+=MOD;
      dif[i+r[j]+1]%=MOD;
    }
    ans[i+1]=(ans[i]+dif[i+1])%MOD;
  }
  cout<<ans[n-1]<<endl;
}


Measured memory_bytes: 8188
#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long int
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int N = 3e3 + 5;
const int lgA = 30;
const int oo = 1e9 + 5;
const LL ooll = 1e18 + 5;
const int MOD = 1e9 + 7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l, r) uniform_int_distribution<int>(l, r)(rng)

int grid[N][N];
LL dp[4][N][N];

void solve() {
    int r, c, k;
    cin >> r >> c >> k;
    for (int i=1;i<=r;++i) for (int j=1;j<=c;++j) {
        grid[i][j] = 0;
        dp[0][i][j] = dp[1][i][j] = dp[2][i][j] = dp[3][i][j] = 0;
    }
    for (int i=0;i<k;++i) {
        int ri, ci, val;
        cin >> ri >> ci >> val;
        grid[ri][ci] = val;
    }
    for (int i=1;i<=r;++i) for (int j=1;j<=c;++j) {
        for (int rc=0;rc<4;++rc) {
            dp[rc][i][j] = max(dp[rc][i][j], dp[rc][i][j-1]);
            dp[0][i][j] = max(dp[0][i][j], dp[rc][i-1][j]);
        }
        for (int rc=3;rc>0;--rc) {
            dp[rc][i][j] = max(dp[rc][i][j], dp[rc-1][i][j] + grid[i][j]);
        }
    }
    cout << max({dp[3][r][c], dp[2][r][c], dp[1][r][c], dp[0][r][c]}) << '\n';
}

int main() {
    FASTIO;
    int T = 1;
    // cin >> T;
    while(T--) {
        solve();
    }
    // cerr << fixed << setprecision(10);
    // cerr << (clock() - start) / ((long double)CLOCKS_PER_SEC) << '\n';
    return 0;
} 

Measured memory_bytes: 320496
i = list(map(int,input().split()))
if (i[0] == i[1] and i[0] != i[2]) or (i[0] == i[2] and i[0] != i[1])  or (i[1] == i[2] and i[1] != i[0]):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9156
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>

using namespace std;
#define INF (1 << 30)

int b(string str){
	int res = 0;
	for(int i = 0;i < str.size();i++){
		res += (str[i] - '0') << i;
	}
	return res;
}

int num[108], n, m;
int dp[1 << 11][1 << 11];


int solve(int asked, int answer){
	int &res = dp[asked][answer];
	if(res != -1)return res;
	int cnt = 0;
	for(int i = 0;i < m;i++){
		if((num[i] & asked) == answer){
			cnt++;
		}
	}
	if(cnt <= 1)return res = 0;
	res = INF;
	for(int i = 0;i < n;i++){
		int p = 1 << i;
		if(asked & p)continue;
		res = min(res, max(solve(asked | p, answer), solve(asked | p, answer | p)) + 1);
	}
	return res;
}

int main(){
	string str;
	while(cin >> n >> m, n | m){
		memset(dp, -1 ,sizeof(dp));
		for(int i = 0;i < m;i++){
			cin >> str;
			num[i] = b(str);
		}
		cout << solve(0, 0) << endl;
	}
	return 0;
}

Measured memory_bytes: 17604
n, k= gets.chomp.split.map(&:to_i)

h = Hash.new(0)

k.times do |i|
  d = gets.chomp.to_i
  a = gets.chomp.split.map(&:to_i)
  

  d.times do |j|
    h[a[j]] += 1
  end
end

puts n- h.size





Measured memory_bytes: 14392
n,m,c=map(int,input().split())
B=list(map(int,input().split()))
counter=0
for i in range(n):
  Ai=list(map(int,input().split()))
  sum=c
  for j in range(m):
    sum+=Ai[j]*B[j]
  if sum>0:
    counter+=1
print(counter)

Measured memory_bytes: 3060
#include <iostream>
#include <limits>
#include <cfenv>
#include <cmath>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <tuple>
#include <queue>
#include <vector>
#include <cmath>
#include <random>
#include <math.h>
#include <list>
#include <random>
#include <functional>


#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define ALL(TheArray) TheArray.begin(), TheArray.end()

using lli = long long int;
using pii = std::pair<int, int>;

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;
}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



int main(void){
    int m1, d1, m2, d2; scanf("%d%d%d%d", &m1, &d1, &m2, &d2);
    puts(m1 == m2 ? "0" : "1");

    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
#include<math.h>
#include<unordered_map>
using namespace std;

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const int mod=10007;
#define ll long long

int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n){
        cin>>a[i];
    }
    int ans=1e9;
    for(int j=-100;j<=100;j++){
        int tmp=0;
        rep(i,n){
            tmp+=(a[i]-j)*(a[i]-j);
        }
        ans=min(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
ans = 0
chk = s[0]
if len(s) == 1:
    print(0)
    exit()
for i in range(1, len(s)):
    if s[i] == chk:
        pass
    else:
        ans += 1
        chk = s[i]
    #print(s[i], ans)
print(ans)

Measured memory_bytes: 3188
N, K, Q = map(int, input().split())
m = {}
mx = 0
for i in range(Q):
    ans = int(input()) - 1
    if ans not in m:
        m[ans] = 1
    else:
        m[ans] += 1
    mx = max(m[ans], mx)
    if mx + K == i:
        break
    

k = list(m.items())
ans = set()
for item in k:
    if item[1] + K > Q:
        ans.add(item[0])

for i in range(N):
    if i in ans:
        print("Yes")
    elif K > Q:
        print("Yes") 
    else:
        print("No")
    


Measured memory_bytes: 15716
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int ninzu=sc.nextInt();
        int haba=sc.nextInt();
        int shai=sc.nextInt();
        System.out.println((ninzu-shai)/(haba+shai));
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    int n;cin >> n;
    vector<LL> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<LL> c(n+1,0);
    for (int i = 0; i < n; i++) {
        c[i+1] = (c[i] + a[i])%mod;
    }
    LL ans = 0;
    for (int i = 0; i < n; i++) {
        ans = (ans + a[n - 1 - i] * c[n - 1 - i])%mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6364
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int N; cin >> N;
    int L[N]; for(int i=0; i<N; i++) cin >> L[i];
    int max_L = 0, sum_L = 0;
    for(int i=0; i<N; i++) { sum_L += L[i]; if (max_L<L[i]) max_L=L[i]; }
    string result = sum_L > max_L * 2 ? "Yes" : "No";
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int inf=1e2+9,MX=1e5+9;
long long  dp[inf][MX],val[inf],weight[inf];
int main(){

    long long  n,w;
    cin>>n>>w;

    for(int i=1;i<=n;i++)
        cin>>weight[i]>>val[i];

    for(int j=1;j<=w;j++){

        for(int i=1;i<=n;i++){

            dp[i][j]=dp[i-1][j];
            if(j-weight[i]>=0)
                dp[i][j]=max(dp[i][j],dp[i-1][j-weight[i]]+val[i]);
        }
    }
    cout<<dp[n][w]<<endl;
}


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

	vector<int>a(n);
	rep(i,n){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	string ans="YES";
	rep(i,n-1){
		if(a[i]==a[i+1]){
			ans="NO";
			break;
		}
	}
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 1024
#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 n;
    cin >> n;
    string s;
    cin >> s;
    int k;
    k=0;
    rep(i,n-2){
        if (s[i]=='A'){
            if (s[i+1]=='B'){
                if (s[i+2]=='C'){
                    ++k;

                

            }
            }
        }
    }
    cout << k << endl;

    return 0;
}

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

int main() {
  int n;
  cin>>n;
  int ans=0;
  vector<int >r(n);
  for(int i=0;i<n;i++){
    cin >>r.at(i);
  }
  int now=r.at(0);
  int mi=1<<30;
  mi*=-1;
  for(int i=1;i<n;i++){
    mi=max(mi,r.at(i)-now);
    if(now>r.at(i)){
      now=r.at(i);
    }
  }
  cout <<mi<<endl;

  return 0;
}



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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)

// Greatest Common Multiple (GCD)
// 2数の最大公約数 by ユークリッド互助法
template <typename T=long long>
T gcd(T a, T b)
{
    if(b == 0) return a;
    else return gcd<T>(b, a % b);
}

// Least Common Multiple (LCM)
// 2数の最小公倍数
template <typename T=long long>
T lcm(T a, T b) {return a * b / gcd<T>( a, b );}

int main()
{
    long long N, M;
    cin >> N >> M;
    vector<long long> a(N);
    REP(i, N) cin >> a[i];

    long long LCM = 1;
    int prev_count = -1;
    REP(i, N){
        a[i] = a[i]/2;
        LCM = lcm<long long>(LCM, a[i]);
        // 2で割れる回数は同じじゃないとダメ
        int count = 0;
        while(a[i]%2 == 0){
            a[i] /= 2;
            ++count;
        }
        if(prev_count == -1) prev_count = count;
        if(prev_count != count or LCM > M){
            cout << 0 << endl;
            return 0;
        }
        prev_count = count;
    }
    cout << (M/LCM+1)/2 << endl;

    return 0;
}

Measured memory_bytes: 1024
#coding:utf-8

tmp = map(int, raw_input().split())

A = tmp[0]
B = tmp[1]

board = []
for i in range(100):
    tmp = []
    for j in range(100):
        if j < 50:
            tmp.append(0)
        else:
            tmp.append(1)
    board.append(tmp)

rest_0 = A - 1
rest_1 = B - 1

flag1 = False
flag2 = False

for i in range(0, 100, 2):
    for j in range(0, 48, 2):
        if rest_1 > 0:
            board[i][j] = 1
            rest_1 -= 1
            if rest_1 == 0:
                flag1 = True


        if rest_0 > 0:
            board[i][50 + j + 2] = 0
            rest_0 -= 1
            if rest_0 == 0:
                flag2 = True

    if flag1 and flag2:
        break

print str(100) + " " + str(100)
#f_w = open("out.txt", "w")
for i in range(100):
    output_list = []
    for j in range(100):
        if board[i][j] == 0:
            output_list.append(".")
        else:
            output_list.append("#")
    output = "".join(output_list)
    print output
    #f_w.write(output + "\n")
#f_w.close()


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

using namespace std;

int main() {
   int k,a,b;
   cin>>k>>a>>b;
   
   int flg=0;
   for(int i=a;i<=b;i++ )
   {
       if(i%k==0)
       {
           flg=1;
           break;
       }
   }
   if(flg)
    cout<<"OK\n";
    else
        cout<<"NG\n";
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello
{
    public static void Main()
    {
        //入力を保持する
        var N = int.Parse(Console.ReadLine());
        var As = Console.ReadLine().Split().Select(e => int.Parse(e)).OrderBy(e => e).ToArray();
        //As配列内に1が1つ存在している場合は1以外は1によりすべて割り切れるため1が回答となる
        if ((As.Count(e => e == 1) == 1))
        {
            Console.WriteLine("1");
            return;
        }
        //1が1よりも多く存在している場合、1も1で割り切れるため0が回答となる
        if ((As.Count(e => e == 1) > 1))
        {
            Console.WriteLine("0");
            return;
        }

        //As配列に含まれる数字の数をカウントするためNがとりうる最大の数分配列を準備する
        var cnt = new int[1000001];
        for (var num = 0; num < N; num++)
        {
            cnt[As[num]] = cnt[As[num]] + 1;
        }
        //Asに含まれる数字の倍数すべてをbool型で保持する
        //-->割り切れないというのは言い換えればAiがその他の数の倍数にならないということ
        var baisuFlgs = new bool[1000001];
        for (var num = 0; num < N; num++)
        {
            var temp = As[num];
            while(temp + As[num] <= 1000000)
            {
                temp = temp + As[num];
                baisuFlgs[temp] = true;
            }
        }

        //cnt配列内にAiの数が1であり、かつbaisuFlags配列内にAiの倍数のインデックスがFalseであればカントアップしていく
        var ans = 0;
        foreach (var i in As)
        {
            if (baisuFlgs[i] == false && cnt[i] == 1)
            {
                ans = ans + 1;
            }
        }
        Console.WriteLine(ans);
    }
}



Measured memory_bytes: 50096
#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
	int eye[2][4]={0};
	double l,r;

	while(scanf("%lf %lf",&l,&r) != EOF){
		if(l>=1.1)               eye[0][0]++;
		else if(l>=0.6 && l<1.1) eye[0][1]++;
		else if(l>=0.2 && l<0.6) eye[0][2]++;
		else if(l<0.2)           eye[0][3]++;

		if(r>=1.1)               eye[1][0]++;
		else if(r>=0.6 && r<1.1) eye[1][1]++;
		else if(r>=0.2 && r<0.6) eye[1][2]++;
		else if(r<0.2)           eye[1][3]++;
	}

	for(int i=0;i<4;i++){
		cout<<eye[0][i]<<" "<<eye[1][i]<<endl;			
	}
	return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

ll N,Q;
string s;

bool is_left_ok(ll pos,char *t,char *d){
    for(ll i = 0; i < Q; i++){
        if(t[i] == s[pos]){
            if(d[i] == 'L')
                pos--;
            else
                pos++;
        }
        if(pos < 0)
            return false;
    }
    return true;
}

bool is_right_ok(ll pos,char *t,char *d){
    for(ll i = 0; i < Q; i++){
        if(t[i] == s[pos]){
            if(d[i] == 'L')
                pos--;
            else
                pos++;
        }
        if(pos >= N )
            return false;
    }
    return true;
}

int main(){
    cin >> N >> Q >> s;
    char t[Q];
    char d[Q];
    for(ll i = 0; i < Q; i++) cin >> t[i] >> d[i];
    
    ll border_left,border_right;
    
    ll left = -1, right = N;
    while(right - left > 1){// [left, right)
        ll mid = left + (right - left) / 2;
        
        if(is_left_ok(mid, t, d)) right = mid;
        else left = mid;
    }
    border_left = right;
    
    left = -1, right = N;
    while(right - left > 1){
        ll mid = left + (right - left) / 2;
        
        if(is_right_ok(mid, t, d)) left = mid;
        else right = mid;
    }
    border_right = right;
    
    ll ans = border_right - border_left;
    cout << ans << "\n";
    return 0; 
} 

Measured memory_bytes: 900
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
int main() {
	long long int a, b, c, k; std::cin >> a >> b >> c >> k;
	std::cout << std::min(k, a) - std::max(k - a - b, 0LL) << std::endl;
}


Measured memory_bytes: 3640
N = int(input())
abc = [[int(j) for j in input().split()] for i in range(N)]
dp = [[0] * 3]
for i in range(N):
    dp += [[max([dp[-1][p] + abc[i][n] for p in range(3) if p != n]) for n in range(3)]]
print(max(dp[-1]))

Measured memory_bytes: 45664
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    char a;
    cin >> a;
    if (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u') {
        cout << "vowel\n";
    } else {
        cout << "consonant\n";
    }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a;
  int mx = 0;
  int sum = 0;
  for(int i = 0; 3 > i; i++){
    cin >> a;
    sum += a;
    mx = max(mx,a);
  } 
  
  cout << sum - mx  << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int K = scan.nextInt();

		String S = scan.next();

		if (S.length() <= K) {
			System.out.println(S);
		} else {
			System.out.println(S.substring(0, K) + "...");
		}

	}

}

Measured memory_bytes: 27072
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
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<typename A,typename B>istream&operator>>(istream&is,pair<A,B> &p){is>>p.fi>>p.se;return is;}
template<typename A,typename B>ostream&operator<<(ostream&os,const pair<A,B> &p){os<<"("<<p.fi<<","<<p.se<<")";return os;}
template<typename T>istream&operator>>(istream&is,vector<T> &t){REP(i,t.size())is>>t[i];return is;}
template<typename T>ostream&operator<<(ostream&os,const vector<T>&t){os<<"{";REP(i,t.size()){if(i)os<<",";os<<t[i];}cout<<"}";return os;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int a,p;
    cin>>a>>p;
    cout<<(a*3+p)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
            result %= MOD

    return result%MOD

def solve():
    n, a, b = [int(_) for _ in input().split()]
    nb = cmb(n, b)
    na = cmb(n, a)
    return (2 ** n)%MOD - 1 - na - nb

if __name__ == '__main__':
    print(solve()%MOD)


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

//first, secondで昇順ソート
bool compare(P a, P b){
    if(a.first == b.first){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

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

    int n,k;
    cin >> n >> k;
    
    vector<vector<ll>> dp(n+1, vector<ll>(n+1, 0));
    
    dp[0][0] = 1;
    
    for(int i=1; i<=n; i++){
        dp[i][0] = dp[i][i] = 1;
        
        for(int j=1; j<=i; j++){
            dp[i][j] = (dp[i-1][j-1] + dp[i-1][j]) % INF;
        }
    }
    
    rep(i,k){
        cout << dp[n-k+1][i+1] * dp[k-1][i] % INF<< endl;
    }

    return 0;
}

Measured memory_bytes: 31616
#include<bits/stdc++.h>
using namespace std;
#define T top()
#define E end()
#define PS push
#define Q queue
#define PP pop()
#define L0 (LL)0
#define V vector
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define DQ deque
#define RE rend()
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define SE second
#define DL double
#define G getline
#define IN insert
#define endl "\n"
#define EM empty()
#define RB rbegin()
#define PSB push_back
#define PI acos(-1.00)
#define PPB pop_back()
#define PSF push_front
#define ub upper_bound
#define lb lower_bound
#define MD 1000000007
#define PPF pop_front()
#define LL long long int
#define PQ priority_queue
#define N cout<<"NO"<<endl
#define Y cout<<"YES"<<endl
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define UOSMOY v.C;w.C;ww.C;u.C;uu.C;uo.C;vo.C;vu.C;ab.C;bc.C;cc.C;uuu.C;a.C;b.C;c.C
V<LL>v;
V<LL>w,ab,bc;
set<LL>uo;
map<LL,LL>u,uc;
map<LL,LL>ww,cc;
LL ar[120005];
LL br[500005];
LL cr[500][500];
V<pair<LL,LL> >uu;
map<LL,V<LL> >uuu;
map<pair<LL,LL>,LL> vo;
map<pair<LL,LL>,LL> vu;
int main()
{
//  BRR;
//  file;
    FAST;
    char ch;
    string a,b,c,str;
    DL x,y,d,e,f,g,h;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r=0;
    while(tt--)
    {
//        UOSMOY;
     cin>>n>>m;
     for(i=0;i<n;i++)
     {
         cin>>o;
         v.PSB(o);
     }
     sort(v.B,v.E);
     k=0;
     for(i=0;i<m;i++)
     {
         k+=v[i];
     }
     cout<<k<<endl;
    }
    return 0;
    //IN
    //AL
}


Measured memory_bytes: 3604
// F# の詳細については、http://fsharp.org を参照してください
// 詳細については、'F# チュートリアル' プロジェクトを参照してください。
open System

[<EntryPoint>]
let main argv = 
  let [| n; k |] = Console.ReadLine().Split(' ') |> Array.map int
  
  let d = 
    Console.ReadLine().Split(' ')
    |> Array.map int
    |> Array.sort
  
  let d' = [ 0..9 ] |> List.filter (fun x -> not (Array.Exists(d, fun y -> x = y)))
  let isOK n = string n |> String.forall (fun x -> List.contains (int x - int '0') d')
  
  let rec solve n = 
    if isOK n then printfn "%d" n
    else solve (n + 1)
  solve n
  0 // 整数の終了コードを返します



Measured memory_bytes: 8776
import scala.annotation.tailrec
import scala.collection.mutable.ArrayBuffer
import scala.io.StdIn._
object Main extends App {


  val n = readInt()
  val num = readLine.trim.split(' ').map(_.toInt)
  val segment = SegmentGCD(num)
  var max = math.max(segment.gcd(1, n), segment.gcd(0, n - 1))
  for (mid ← 1 until n - 1){
    val g = gcd(segment.gcd(0, mid), segment.gcd(mid + 1, n))
    if (max < g) max = g
  }
  println(max)

  @tailrec private[this] def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)
}
object SegmentGCD {
  def apply(numbers: Array[Int]): SegmentGCD = {
    val array = ArrayBuffer[Array[Int]](numbers)
    while(array.last.length != 1){
      array.append(Array.fill((array.last.length + 1) / 2){0})
    }
    for (i ← 1 until array.length; j ← array(i).indices){
      array(i)(j) = if (array(i - 1).length <= j * 2 + 1) array(i - 1)(j * 2)
      else gcd(array(i - 1)(j * 2), array(i - 1)(j * 2 + 1))
    }
    new SegmentGCD(array.toArray)
  }

  @tailrec def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)
}
class SegmentGCD private (private val array: Array[Array[Int]]) {
  def gcd(from: Int, until: Int): Int = {
    var result = array(0)(from)
    var begin = from
    var end = until - 1
    for (i ← array.indices if begin <= end) {
      if (begin % 2 == 1) {
        result = SegmentGCD.gcd(result, array(i)(begin))
      }
      if (end % 2 == 0){
        result = SegmentGCD.gcd(result, array(i)(end))
      }
      begin = (begin + 1) / 2
      if (end != 0) end = (end - 1) / 2
      else end = -2
    }
    result
  }
}

Measured memory_bytes: 60496
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int output = 0;
      for(int i = 1; i <= N; i++){
        String tmp = String.valueOf(i);
        if(tmp.length() % 2 == 1){
          output++;
        }
      }
      System.out.println(output);
	}
}

Measured memory_bytes: 27732
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;


int main() {
	int n; cin >> n;
	int w = n;
	int cnt = 0;
	while (w > 0) {
		cnt++;
		w /= 10;
	}
	int ans = 0;
	for (int i = 1; i < cnt; i++) {
		if (i & 1) {
			ans += (int)pow(10, i) - (int)pow(10, i - 1);
		}
	}
	if (cnt & 1) {
		ans += n - (int)pow(10, cnt - 1) + 1;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N, M, L = (int(i) for i in input().split())

import numpy as np
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

graph = [[0]*N for i in range(N)]
for i in range(M):
    a, b, c = (int(i) for i in input().split())
    graph[a-1][b-1] = c
    graph[b-1][a-1] = c

graph = csr_matrix(graph)
d = floyd_warshall(csgraph=graph, directed=False)

new_graph = [[0]*N for i in range(N)]
for i in range(N):
    for j in range(N):
        if d[i][j] <= L:
            new_graph[i][j] = 1
            new_graph[j][i] = 1

graph = csr_matrix(new_graph)
d = floyd_warshall(csgraph=graph, directed=False)
Q = int(input())
for i in range(Q):
    s, t = (int(i) for i in input().split())
    if d[s-1][t-1] == float("inf"):
        print("-1")
    else:
        print(int(d[s-1][t-1]-1))

Measured memory_bytes: 23864
import java.util.*;
import java.io.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        
        int n = input.nextInt();
        int[] S = new int[n];
        for (int i = 0; i < n; i++) S[i] = input.nextInt();
        
        int q = input.nextInt();
        int[] T = new int[q];
        for (int i = 0; i < q; i++) T[i] = input.nextInt();
        
        Arrays.sort(S);
        Arrays.sort(T);
        
        int i = 0, j = 0, count = 0;
        while (j < q && i < n) {
            if (S[i] < T[j]) {
                i++;
            } else if (S[i] == T[j]) {
                count++;
                while (i < n && S[i] == T[j]) i++;
            } else {
                j++;
            }
        }
        
        System.out.println(count);
    }
    
    private void print(Object[] xs) {
        StringBuilder sb = new StringBuilder();
        for (Object x : xs) sb.append(x.toString()).append(' ');
        System.out.println(sb.toString().trim());
    }
    
    private static class Scanner {
        BufferedReader r;
        StreamTokenizer st;
        
        public Scanner(InputStream in) {
            r = new BufferedReader(new InputStreamReader(in));
            st = new StreamTokenizer(r);
        }
        
        public String next() {
            nextToken();
            return st.sval;
        }
        
        public Integer nextInt() {
            nextToken();
            return (int)st.nval;
        }
        
        private int nextToken() {
            int token = st.TT_EOF;
            try {
                token = st.nextToken();
            } catch (IOException e) {
            }
            return token;
        }
    }
}

Measured memory_bytes: 29676
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define debug cout<<"****************"<<endl
using namespace std;
typedef long long ll;
inline void ju() {
	freopen("***.in","r",stdin);
	freopen("***.out","w",stdout);
}
inline ll rd() {
	ll x=0,f=1; char c=getchar();
	while((c<'0'||c>'9')&&(c!='-')) c=getchar();
	if(c=='-') f=-1,c=getchar();
	while(c>='0'&&c<='9') {
		x=(x<<3)+(x<<1)+c-'0';
		c=getchar();
	}
	return x*f;
}
inline ll tri(ll x) {
	return x*x*x;
}
int main() {
	ll n=rd(),k=rd();
	//printf("%lld %lld\n",tri(n/k),(k%2==0)?tri((n+k/2)/k):0);
	printf("%lld\n",tri(n/k)+((k%2==0)?tri((n+k/2)/k):0));
	return 0;
}


Measured memory_bytes: 256
import math

input_from = input()
info = input_from.split(' ')
a = int(info[0])

def is_prime(n):
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    for num in range(3, int(math.sqrt(n)), 2):
        if n % num == 0:
            return False
    return True

if a > 2:
    if a % 2 == 0:
        a += 1
    while not is_prime(a):
        a += 2

print("{0}".format(a))


Measured memory_bytes: 3060