akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ
{
    class Program
    {
        static IEnumerable<T> Read<T>(int N, Func<int, int, T> f)
        {
            for(int i = 0; i < N; i++)
            {
                var line = Console.ReadLine().Split(',').Select(int.Parse).ToArray();
                yield return f(line[0], line[1]);
            }
        }

        private static Pair[,] pairs;
        static void Main(string[] args)
        {
            string line;
            int @case = 1;
            while((line = Console.ReadLine()) != null)
            {
                if (line == "0") break;
                var W = int.Parse(line);
                var N = int.Parse(Console.ReadLine());
                pairs = new Pair[N + 1, W + 1];
                var data = Read(N, (a, b) => new {a, b}).ToArray();
                var total = F(0, W, data, x => x.a, x => x.b);
                Console.WriteLine("Case {0}:", @case);
                @case++;
                Console.WriteLine(total.Item1);
                Console.WriteLine(W - total.Item2);
            }
        }

        class Pair
        {
            public int Item1;
            public int Item2;

            public Pair(int item1, int item2)
            {
                Item1 = item1;
                Item2 = item2;
            }

            public void Add(Pair rhs)
            {
                Item1 += rhs.Item1;
                Item2 += rhs.Item2;
            }
        }
        static Pair F<T>(int i, int weightRemain, T[] data, Func<T, int> valueSelector, Func<T, int> weightSelector)
        {
            if (pairs[i, weightRemain] != null) return pairs[i, weightRemain];
            if (i == data.Length)
            {
                return pairs[i, weightRemain] = new Pair(0, weightRemain);
            }
            var remains = F(i + 1, weightRemain, data, valueSelector, weightSelector);
            var weight = weightSelector(data[i]);
            if (weight > weightRemain) return pairs[i, weightRemain] = remains;
            var whole = new Pair(valueSelector(data[i]), 0);
            whole.Add(F(i + 1, weightRemain - weight, data, valueSelector, weightSelector));
            if (whole.Item1 == remains.Item1) return pairs[i, weightRemain] = (whole.Item2 >= remains.Item2 ? whole : remains);
            return pairs[i, weightRemain] = (whole.Item1 >= remains.Item1 ? whole : remains);
        }
    }
}

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

int main(void){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    ll cnt=0;
    for(int i=1;i<n;i++){
        if(a[i-1]>a[i]){
            cnt+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3964
from collections import Counter
n = int(input())
num = list(map(int, input().split()))
num1 = []
num2 = []
ans = 0

for i in range(0, n, 2):
    num1.append(num[i])
    
for i in range(1, n, 2):
    num2.append(num[i])

num1 = Counter(num1).most_common()
num2 = Counter(num2).most_common()    

if num1[0][0] != num2[0][0]:
    ans = n - num1[0][1] - num2[0][1]
else:
    if n - num1[0][1] - num2[0][1] == 0:
        ans = n // 2
    else:
        if n // 2 - num1[0][1] == 0:
            ans = n // 2 - num2[1][1]
        elif n // 2 - num2[0][1] == 0:
            ans = n // 2 - num1[1][1]
        else:
            a = n - num1[0][1] - num2[1][1]
            b = n - num1[1][1] - num2[0][1]
            ans = min(a, b)

print(ans)

Measured memory_bytes: 20828
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int a, b, k;
  cin >> a >> b >> k;
  for(int i=min(a,b);i>=1;i--) {
    if(a%i == 0 && b%i == 0) 
      k--;
    if(k == 0) {
      cout << i;
      return 0;
    }
  }
}

Measured memory_bytes: 256
package main

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

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  sc.Scan()
  sc.Scan()
  g, _ := strconv.Atoi(sc.Text())

  sc.Scan()
  b, _ := strconv.Atoi(sc.Text())

  if (g * 10 + b) % 4 == 0 {
    fmt.Println("YES")
  } else {
    fmt.Println("NO")
  }

}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long a,b,c,k;
  cin>>a>>b>>c>>k;
  long long sum=0;
  if(k>0)
  {
    sum+=min(a,k);
    k=k-min(a,k);
    
  }
  if(k>0)
  {
      k=k-min(b,k);
  }
  if(k>0)
  {
    sum=sum-min(c,k);
    
  }
  cout<<sum;
  return 0;
}

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

int main() {
    string s;
    cin >> s;
    int count = 0;

    for(int i=0; i<s.size()/2; i++) {
        if(s.at(i) != s.at(s.size()-1-i)) {
            count++;
        }
    }

    cout << count << endl;
}

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

int main() {
  int x,x1,x2,x3;
  cin >> x;
  x1 = x/100;
  x2 = (x-(100*x1))/10;
  x3 = x-(10*x2)-(100*x1);
  cout << x1+x2+x3 << endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
MOD=10**9+7
ans=0
for i in range(60):
    a,b=0,0
    for j in range(N):
        if A[j]%2==0:
            a=a+1
        else:
            b=b+1
        A[j]=A[j]//2
    ans=(ans+(a*b)*2**i)%MOD
print(ans)

Measured memory_bytes: 122808
#include<bits/stdc++.h>
#define mod 1000000007
#define f first
#define s second

using namespace std;

/*int gcd(int a,int b){
	if(b == 0)
		return a;
	return gcd(b,a%b);
}*/

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
  	int n;
  	cin>>n;
  
  	cout<<(n -2)*180;



	return 0;
}

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

def calc():
  n=int(input())
  arr=list(map(int,input().split()))
  l=int(input())
  pos=0
  dbl=[[0]*(n+1)]
  for i in range(n):
      dbl[0][i+1]=bisect.bisect_right(arr,arr[i]+l)
  for _ in range(n.bit_length()-1):
    tmp=[0]*(n+1)
    for i in range(n+1):
      tmp[i]=dbl[-1][dbl[-1][i]]
    dbl.append(tmp)
  q=int(input())
  for _ in range(q):
    a,b=map(int,input().split())
    if a>b:
      a,b=b,a
    l=0
    r=b-a+1
    while r-l!=1:
      mid=(l+r)//2
      tmp=a
      for i in range(mid.bit_length()):
        if mid&(1<<i):
          tmp=dbl[i][tmp]
      if tmp>=b:
        r=mid
      else:
        l=mid
    print(r)
calc()

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

int main(){
long A, B, K;
  cin >> A >> B >> K;
if(A >= K){
  A -= K;
}else if(B >= K-A){
  B =B- (K-A);
  A = 0;
}else{
A = 0;
  B = 0;
}
cout << A << " " << B << endl;
}


Measured memory_bytes: 256
s=input()
aflag=0
bflag=0
cflag=0
for i in range(3):
  if s[i]=='a':
    aflag+=1
  if s[i]=='b':
    bflag+=1
  if s[i]=='c':
    cflag+=1
if aflag==1 and bflag==1 and cflag==1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    VEC(int) V(3);
    READVEC(V);
    sort(ALL(V));

    if ((V[0] + V[1]) % 2 == 0) {
        cout << V[2] - (V[0] + V[1]) / 2;
    }
    else 
        cout << 1 + V[2] - (V[0] + V[1]) / 2;
    cout << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};

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

using namespace std;

#define int long long

string s;
int ans;

int32_t main() {
    cin >> s;
    int n = s.size();
    ans = n;
    for (int i = 0; i + 1 < n; i++)
	if (s[i] != s[i + 1])
	    ans = min(ans, max(i + 1, n - i - 1));
    return cout << ans, 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define  ll  long long int
using namespace std;


int main()
{
    double x,y,z,n;
    cin>>n;


    x=n/3.0;

    n=n-x;

    y=n/2.0;

    z=n-y;

    double an=x*y*z;

    printf("%0.12lf\n",an);
    return 0;
}


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

int main(){
    int N;
    cin >> N;

    //n1に下3桁、n2に上3桁を入れる
    int n1, n2;
    n1 = N % 1000;
    n2 = N / 10;

    if (n1 % 111 == 0 || n2 % 111 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

}

Measured memory_bytes: 256
open Printf
open Scanf

let () =
  let n = scanf "%d " (fun x -> x) in
  let rec read i =
    if i = 0 then []
    else let v = scanf "%d " (fun x -> x) in
         v :: read (i - 1) in
  let ls = read n in
  let rec expt3 n =
    if n = 0 then 1 else 3 * (expt3 (n - 1)) in
  expt3 n - (List.fold_left (fun a x -> if x mod 2 = 0 then a * 2 else a) 1 ls) |> printf "%d\n"


Measured memory_bytes: 2432
#include<iostream>
using namespace std ;
int main(){
    int a,b;
    cin>>a>>b;
    if(a<b)
    cout<<"a < b"<<endl;
    else {if (a==b)
    cout<<"a == b"<<endl;
     else   cout<<"a > b"<<endl;}
    return 0 ;

}



Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<LL, LL> P;

int main(void)
{
  char c;
  cin >> c;

  if (c == 'A') {
    cout  << 'T' << endl;
  }
  else if (c == 'T') {
    cout << 'A' << endl;
  }
  else if (c == 'C') {
    cout << 'G' << endl;
  }
  else {
    cout << 'C' << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
const int maxn=2e5+10;
const int N=2e5+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
int n,m,k,t,c[maxn],w[maxn],id[maxn],mi[maxn],pos[maxn],x,y,qu[maxn],cnt[maxn],all;
vi e[maxn];
ll fac[maxn],inv[maxn];
bool vis[maxn];
ll ret=1;
void init()
{
    fac[0]=1;
    for(int i=1;i<=maxn-10;i++)fac[i]=fac[i-1]*i%mod;
    inv[maxn-10]=qpow(fac[maxn-10],mod-2);
    for(int i=maxn-11;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
}
bool cmp(int x,int y){return mi[x]<mi[y];}
void dfs(int x)
{
    all++;
    vis[x]=true;
    if(++cnt[c[x]]==1)qu[++qu[0]]=c[x];
    for(int y:e[x])
    {
        if(!vis[y])dfs(y);
    }
}
int main()
{
    int i,j;
    init();
    scanf("%d%d%d",&n,&x,&y);
    rep(i,1,n)mi[i]=1e9,id[i]=i;
    rep(i,1,n)
    {
        scanf("%d%d",&c[i],&w[i]);
        if(mi[c[i]]>=w[i])mi[c[i]]=w[i],pos[c[i]]=i;
    }
    sort(id+1,id+n+1,cmp);
    rep(i,1,n)
    {
        if(mi[c[i]]+w[i]<=x)
        {
            e[i].pb(pos[c[i]]);
            e[pos[c[i]]].pb(i);
        }
        if(id[1]!=c[i]&&mi[id[1]]+w[i]<=y)
        {
            e[i].pb(pos[id[1]]);
            e[pos[id[1]]].pb(i);
        }
        if(n>1&&id[2]!=c[i]&&mi[id[2]]+w[i]<=y)
        {
            e[i].pb(pos[id[2]]);
            e[pos[id[2]]].pb(i);
        }
    }
    rep(i,1,n)
    {
        if(!vis[i])
        {
            qu[0]=0;
            all=0;
            dfs(i);
            ll tmp=fac[all];
            rep(j,1,qu[0])tmp=tmp*inv[cnt[qu[j]]]%mod,cnt[qu[j]]=0;
            ret=ret*tmp%mod;
        }
    }
    printf("%lld\n",ret);
    return 0;
}


Measured memory_bytes: 21352
#include<cstring>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
using namespace std;
const long long Maxn=1e6;
typedef long long ll;


ll a[Maxn];
ll op;

bool cmp(ll x,ll y){
	return fabs(x-op)<fabs(y-op);
}

int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	sort(a+1,a+1+n); printf("%lld ",a[n]);
	if(a[n]%2==0) op=a[n]/2;
	else op=a[n]/2+1;
	sort(a+1,a+n,cmp);
	printf("%lld\n",a[1]);
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define fix(n) cout<<fixed<<setprecision(n);
#define rep(i,n)   for (int i = 0; i < (n); ++i)
#define sort(a)    sort((a).begin(), (a).end());
#define uniq(a)    SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define reverse(a) reverse((a).begin(), (a).end());
#define out(d) cout << (d);
#define outl(d) std::cout<<(d)<<"\n";
#define Yes() printf("Yes\n");
#define No() printf("No\n");
#define YES() printf("YES\n");
#define NO() printf("NO\n");
#define ceil(x, y) ((x + y - 1) / (y))

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12)

  ll n; cin >> n;
  if (n < 1200)
    outl("ABC")
  else
    outl("ARC")
}


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    long long x, y;
    cin >> x >> y;

    int sum = 0;
    int ans = 0;
    if(a + b <= c * 2){
        sum = a + b;
        if(x < y){
            ans += sum * x;
            ans += b * (y - x);
        }else if(x == y){
            ans += sum * x;
        }else{
            ans += sum * y;
            ans += a * (x - y);
        }
    }else{
        sum = c * 2;
        if(x < y){
            ans += sum * x;
            if(b <= sum){
                ans += b * (y - x);
            }else{
                ans += sum * (y - x);
            }
        }else if(x == y){
            ans += sum * x;
        }else{
            ans += sum * y;
            if(a <= sum){
                ans += a * (x - y);
            }else{
                ans += sum * (x - y);
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	int n, x;
	cin >> n >> x;
	if(x == 1 || x == 2*n-1) {
		cout << "No" << endl;
		return 0;
	}
	deque<int> ans, d;
	ans.pb(x);
	rep(i, 2*n-1) if(i+1 != x) d.pb(i+1);
	while(!d.empty()) {
		ans.pb(d.back()); d.pop_back();
		ans.push_front(d.front()); d.pop_front();
	}
	cout << "Yes" << endl;
	rep(i, ans.size()) {
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 2304
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A, B, C):
    A.sort()
    B.sort()
    C.sort()

    D = [0] * (N+1)
    for i in range(N-1, -1, -1):
        j = bisect.bisect_right(C, B[i])
        D[i] = D[i+1] + (N-j)

    ans = 0
    for i in range(N-1, -1, -1):
        j = bisect.bisect_right(B, A[i])
        ans += D[j]

    return ans


def main():
    N = read_int()
    A = read_int_n()
    B = read_int_n()
    C = read_int_n()
    print(slv(N, A, B, C))


if __name__ == '__main__':
    main()


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n,m;
  cin >> n >> m;
  vl pa(n);
  REP(i,n) pa[i] = i;
  REP(i,m) {
    ll ai,bi,d;
    cin >> ai >> bi >> d;
    ai--;
    bi--;
    while(ai!=pa[ai])ai = pa[ai];
    while(bi!=pa[bi])bi = pa[bi];
    ll mp = min(pa[ai],pa[bi]);
    pa[ai] = mp;
    pa[bi] = mp;
  }
  vector<bool> incl(n,false);
  ll ans = 0;
  REP(i,n){
    ll node = i;
    while(pa[node]!=node){
      node = pa[node];
    }
    if(!incl[node]){
      incl[node] = true;
      ans++;
    }
  }
  cout << ans<< endl;
  return 0;
}


Measured memory_bytes: 1024
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<algorithm>
#include<bitset>
#include<complex>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<stack>
#include<set>
using namespace std;
string a;
int ans;
int main()
{
	cin>>a;
	getchar();
	for (int i=0;i<a.length();++i)
		if (getchar()!=a[i])
			++ans;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3356
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e9;
#define sz              3000005
#define Fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


int main(){
    Fast;

    int l, r, d;
    cin>>l>>r>>d;
    int cnt=0;
    for(int i=l; i<=r; i++){
        if(i%d==0)cnt++;
    }
    cout<<cnt<<endl;




    return 0;
}



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

using namespace std;
constexpr int64_t MOD = 1'000'000'007;
constexpr int MAX = 110000;

int64_t fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
int64_t COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void) {
    int n;
    cin >> n;

    int l, r;
    vector<int> L(n+2);
    for(int i=1; i<=n+1; i++) {
        int a;
        cin >> a;
        if(L[a]) {
            l = L[a] - 1;
            r = n+1 - i;
        } else {
            L[a] = i;
        }
    }

    COMinit();

    cerr << l << " " << r << endl;

    for(int k=1; k<=n+1; k++) {
        int64_t ans = COM(n+1, k) - COM(l+r, k-1);
        if(ans < 0) ans += MOD;
        cout << ans << endl;
    }
    return 0;
}


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

int n;
int u[101], k[101], d[101];
vector<vector<int>> g;
queue<pair<int, int>> q;

int main() {
	cin >> n;
	g.resize(n+1);
	for(int i=1;i<=n;i++){
		d[i] = -1;
		cin >> u[i] >> k[i];
		if(k[i]){
			for(int j=0;j<k[i];j++){
				int v; cin >> v;
				g[u[i]].push_back(v);
			}
		}
	}
	q.push({1,0});
	while(!q.empty()){
		int a = q.front().first;
		d[a] = q.front().second;
		q.pop();
		for(auto c: g[a]){
			if(d[c]!=-1) continue;
			else{
				d[c] = d[a]+1;
				q.push(make_pair(c, d[c]));
			}
		}
	}
	for(int i=1;i<=n;i++){
		cout << i << ' ' << d[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 3172
def comb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


mod = 10**9+7  # 出力の制限
N = 10**6
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)


MOD = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))

appeared = set()
dup_right = 0
dup = 0
for i, x in enumerate(a):
    if x in appeared:
        dup_right = n - i
        dup = x
        break
    appeared.add(x)
dup_left = 0
for i, x in enumerate(a):
    if x == dup:
        dup_left = i
        break

for k in range(1, n + 2):
    print((comb(n + 1, k, MOD) - comb(dup_right + dup_left, k - 1, MOD) + MOD) % MOD)


Measured memory_bytes: 213024
#include<bits/stdc++.h>
#define REP(i,x) for(int i=0,i##_len=(x);i<i##_len;++i)
#define rep(i,a,b) for(int i=(a),i##_len(b);i<i##_len;++i)
#define All(x) begin(x),end(x)
#define rAll(x) rbegin(x),rend(x)
using namespace std;
using ll = long long;

int main(){
    int N;
    cin>>N;
    vector<int> x(N),y(N);
    REP(i,N) cin>>x[i]>>y[i];
    vector<int> ord(N);
    iota(All(ord),0);
    double ans=0;
    do{
        double tmp=0;
        REP(i,N-1){
            int dx=x[ord[i+1]]-x[ord[i]],dy=y[ord[i+1]]-y[ord[i]];
            tmp+=sqrt(dx*dx+dy*dy);
        }
        ans+=tmp;
    }while(next_permutation(All(ord)));
    ll n=1;
    REP(i,N) n*=i+1;
    printf("%.16f",ans/double(n));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, l, r;	// N:団体数　l:席はじめ　r:席終わり
  int sum = 0; 		// sum:人数合計
  
  cin >> N;		// 団体数入力
  for(int i = 0; i<N ; i++){
    cin >> l >> r;		//席入力
    sum += r - l +1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
def main():
    S = input()
    k = int(input())
    if len(set(list(S))) == 1:
        print(len(S) * k // 2)
        exit()
    A = []
    cnt = 1
    tmp = S[0]
    for s in S[1::]:
        if s == tmp:
            cnt += 1
        else:
            A.append(cnt)
            tmp = s
            cnt = 1
    A.append(cnt)
    ans = sum([a // 2 for a in A])
    if S[0] == S[-1]:
        A[0] += A[-1]
        A.pop()
    ans += sum([a // 2 for a in A]) * (k - 1)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
a = list(map(int, input().split()))
vec = [a[2] - a[0], a[3] - a[1]]
res = [0,0,0,0]
res[2] = a[0] - vec[1]
res[3] = a[1] + vec[0]

res[0] = res[2] + vec[0]
res[1] = res[3] + vec[1]

print(res[0], res[1], res[2], res[3])


Measured memory_bytes: 3316
import sys
from collections import deque
input = sys.stdin.readline

S = input()

dq = deque(S.rstrip())
Q = int(input());

reverse = False

for _ in range(Q):
    q = input().split()
    if q[0] == '1':
        reverse ^= 1
    else:
        F, C = q[1:]
        if reverse:
            if F == '1':
                dq.append(C)
            else:
                dq.appendleft(C)
        else:
            if F == '1':
                dq.appendleft(C)
            else:
                dq.append(C)

ans = ""
if reverse:
    while dq:
        ans += dq.pop()
else:
    while dq:
        ans += dq.popleft()
print(ans)

Measured memory_bytes: 6408
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i, n)         for(int i=0; i<n; i++)
#define fo(i, k, n)     for(int i=k; i<n; i++)
#define forr(i, a, b)   for(int i=a; i<=b; i++)
#define rf(i,n)         for(int i=n;i>=0;i--)
typedef unsigned long long ull;
typedef pair<int ,int> pr;
#define MAX 100005
#define INF 1000000009
#define   sq(n)         (n*n)
#define p(n) cout<<n<<endl
#define pb push_back
#define py cout<<"YES"<<endl;
#define pn cout<<"NO"<<endl;
#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
ll lcm ( ll a, ll b )
{
    return ( a / __gcd ( a, b ) ) * b;
}
int main()
{
    __FastIO;

     int n,k;
     cin>>n>>k;
     int a[n+1];
     f(i,n)
     {
         cin>>a[i];
     }
     sort(a,a+n);
     int s=0;
     f(i,k)
     {
         s+=a[i];
     }
     cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <numeric>
#include <string>
#include <cstring>
#include <cmath>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long int int64;


const int N = 10;
char f[N][N];


int main(int,  char **)
{
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++)
        scanf("%s", f[i]);

    int cnt = 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            if (f[i][j] == '#')
                cnt++;

    int xcnt = 1;
    int i = 0, j = 0;
    while (true)
    {
        if (f[i][j + 1] == '#')
        {
            xcnt++;
            j++;
        }
        else if (f[i + 1][j] == '#')
        {
            xcnt++;
            i++;
        }
        else
            break;
    }

    printf(cnt == xcnt ? "Possible\n" : "Impossible\n");


	return 0;
}




Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


class node_t {
public:
  node_t(int xx, int cc, int ii) : x(xx), c(cc), i(ii) {};

public:
  int x;
  int c;
  int i;
};


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, M, a, b, c;

  std::cin >> N >> M;

  std::vector<std::vector<node_t>> G(N);

  for (int i = 0; i < M; i ++) {
    std::cin >> a >> b >> c;

    a --;
    b --;

    G[a].emplace_back(b, c, i);
    G[b].emplace_back(a, c, i);
  }

  bool used[1111] = {0};

  for (int i = 0; i < N; i ++)
    for (int j = i + 1; j < N; j ++) {
      int dist[111], parent[111], edge[111];

      memset(dist, 0x3f, sizeof(dist));

      dist[i] = 0;

      parent[i] = -1;

      std::priority_queue<std::pair<int, int>> pq;

      pq.emplace(- 0, i);

      while (! pq.empty()) {
        int d, x;

        std::tie(d, x) = pq.top(); pq.pop();

        if (x == j) {
          for ( ; parent[x] >= 0; x = parent[x])
            used[edge[x]] = true;

          break;
        }
          
        for (const auto& node : G[x]) {
          int dd = (- d) + node.c;

          if (dd < dist[node.x]) {
            dist[node.x] = dd;

            parent[node.x] = x;
            edge  [node.x] = node.i;

            pq.emplace(- dd, node.x);
          }
        }
      }
    }

  std::cout << std::count(used, used + M, false) << std::endl;
  
  return 0;
}


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

namespace ALDS1_4_C
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            HashSet<string> dic = new HashSet<string>();
            for (int i = 0 ; i < n ; i++)
            {
                string[] line = ReadStAr();
                switch (line[0])
                {
                    case"insert":
                        dic.Add(line[1]);
                        break;
                    case "find":
                        string res = dic.Contains(line[1]) ? "yes" : "no";
                        Console.WriteLine(res);
                        break;
                }
            }
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 45476
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>
#include <atcoder/all>


using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;


#define REP(i, n) for(ll i = 0; i < n; i++)





















class Unionfind {
private:
    vector<int> par;
    vector<int> rank;
    vector<int> counter;
    
public:
    Unionfind(int n) : rank(n), counter(n, 1){
        for(int i = 0; i < n; i++){
            par.push_back(i);
        }
    }
    
    int find(int x){
        if (par[x] == x) {
            return x;
        }
        else {
            return par[x] = find(par[x]);
        }
    }
    
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if (x == y) return;
        
        if (rank[x] < rank[y]) {
            counter[y] += counter[x];
            counter[x] = counter[y];
            par[x] = y;
        }
        else {
            counter[y] += counter[x];
            counter[x] = counter[y];
            par[y] = x;
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
    }
    
    bool same(int x, int y){
        return find(x) == find(y);
    }
    
    ll count(int x){
        return counter[find(x)];
    }
};

int main(){
    ll n, q;
    cin >> n >> q;
    Unionfind uni(n);
    REP(i, q){
        ll t, u, v;
        cin >> t >> u >> v;
        if(t == 0){
            uni.unite(u, v);
        }
        else{
            cout << uni.same(u, v) << endl;
        }
    }
}

Measured memory_bytes: 5756
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>

using namespace std;

int main()
{
  int w;
  
  while ( cin >> w )
    {
      bool flag = false;
      
      for ( auto i = 0; i < 10; ++i )
        {
          if ( (w >> i) & 1 )
            {
              if ( flag ) cout << " ";
              flag = true;
              cout << (1 << i);
            }
        }
      cout << endl;
    }
  return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<ll,ll>;
#define For(i,a,b)  for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define bpc __builtin_popcount
#define MOD (ll)(1e9+7)
#define INF (2e9)
#define EPS (1e-6)
#define NATHANLEE_IS_EVIL_AND_ELECTRIC true
#define int ll
#ifdef LOCAL_TEST
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<"\n";}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif
void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(!NATHANLEE_IS_EVIL_AND_ELECTRIC);
	cin.tie(0);
}

ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll fpow(ll b,ll p){
	b%=MOD;
	ll ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

struct Node{
	vector<int> from,to;
	int ans=0,cnt=0;
}g[100010];

int32_t main() {
	INIT();
	//code...
	int n,m; cin>>n>>m;
	int s,t;
	For(i,0,m-1){
		cin>>s>>t;
		s--; t--;
		g[s].to.eb(t);
		g[t].from.eb(s);
	}
	queue<int> que;
	For(i,0,n-1){
		if(sz(g[i].from)==0){
			que.emplace(i);
		}
	}
	while(!que.empty()){
		int now=que.front(); que.pop();
		for(auto &i:g[now].to){
			g[i].cnt++;
			g[i].ans=max(g[i].ans,g[now].ans+1);
			if(g[i].cnt==sz(g[i].from)) que.emplace(i);
		}
	}
	int ans=0;
	For(i,0,n-1) ans=max(ans,g[i].ans);
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 16020
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int a;
    cin >> a;
    cout << a * a << endl;
}

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

using namespace std;

int main()
{
	array<int, 3> x;
	cin >> x[0] >> x[1] >> x[2];
	sort(x.begin(), x.end());
	int y = x[2] - x[1] + x[2] - x[0];
	cout << (y % 2 == 0 ? y/2 : (y+3)/2) << endl;
	return 0;
}


Measured memory_bytes: 256
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0;
    cin>>n;
    int x=n%10;
    if(x==2||x==4||x==5||x==7||x==9)
        cout<<"hon";
    else if(x==0||x==1||x==6||x==8)
        cout<<"pon";
    else
        cout<<"bon";
    cout<<endl;
}


Measured memory_bytes: 3652
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map { it.toLong() }

    val x = n % k
    var sub = x - k
    sub = if (sub < 0) sub * -1
    else sub
    if (sub < x) println(sub)
    else println(x)
}


Measured memory_bytes: 38208
#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<string.h>
using namespace std;


int main()

{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	string a,b; cin >>a>>b; bool k = true;
	

	for (int i = 0; i < 3; i++) {
		if (a[2-i] != b[i]) {
			k = false; break;
		}
	}
	if (k == true)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;

}

Measured memory_bytes: 3640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class A
{
	public static void Main()
	{
		int X = Int32.Parse(Console.ReadLine());
		string ans = null;
		switch(X)
		{
			case 7:
			case 5:
			case 3:
				ans = "YES";
				break;
				
			default:
				ans = "NO";
				break;			
		}
		Console.WriteLine(ans);
	}	
}





Measured memory_bytes: 11092
import java.util.Scanner;

class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		String str=sc.next();
		StringBuilder s=new StringBuilder();
		for(int i=str.length()-1;i>=0;i--){
			s.append(str.charAt(i));
		}
		ln(s);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

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

int main(){
int m,n,q,i,j,S[10000],T[500];
m=0;
scanf("%d",&n);
for(i=0;i<n;i++){
    scanf("%d",&S[i]);
   }

scanf("%d",&q);
for(i=0;i<q;i++){
    scanf("%d",&T[i]);
    }

for(i=0;i<q;i++){
    for(j=0;j<n;j++){
        if(T[i]==S[j]){
          m++;
          break;
        }
      }
    }
printf("%d\n",m);
return 0;
}

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

int main() {
  string str;
  cin >> str;

  int count = 0;
  for (int i = 0; i < str.size(); i++) {
    if (str.at(i) == '?') {
      str.at(i) ='D';
    }
  }

  cout << str << endl;
}

Measured memory_bytes: 3756
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()
print(S.count("1"))


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int n,m;
string s[12],t;
int len[12];
int match[5000];
bool dp[5001][1<<12];

int main(){
  while(1){
    cin>>n>>m;
    if(n==0)break;
    rep(i,n){
      cin>>s[i];
      len[i]=s[i].size();
    }
    t="";
    rep(i,m){
      string in;
      cin>>in;
      t+=in;
    }
    m=t.size();
    rep(i,m){
      match[i]=0;
      rep(j,n){
        if(m-i<len[j])continue;
        if(t.substr(i,len[j])==s[j])match[i]|=(1<<j);
      }
    }
    rep(i,m+1)rep(j,1<<n)dp[i][j]=false;
    rep(i,m){
      dp[i][0]=true;
      rep(S,1<<n){
        if(!dp[i][S])continue;
        rep(j,n){
          if(((S>>j)&1)==0&&((match[i]>>j)&1)==1)dp[i+len[j]][S|(1<<j)]=true;
        }
      }
    }
    int res=0;
    rep(i,m+1)if(dp[i][(1<<n)-1]){
      res++;
    }
    cout<<res<<endl;
  }
  return 0;
}



Measured memory_bytes: 23200
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val x = readInt()
    
    var pt = 0
    var i = 1
    while(pt < x) {
        pt += i
        i++
    }
    println(i-1)
    
    pw.flush()
}

/****** Decrared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }

fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j] % MOD)
        }
    }
    val rtn = v.map { it.toList() }.toList()
    return rtn 
}

fun gcd(a: Long, b: Long): Long = 
if(b != 0L) a else gcd(b, a % b)

fun lcm(a: Long, b: Long) = 
if(b==0L) a else gcd(b, a % b)

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 31648
package main

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

func main() {
	s := IOInitialize()
	N := Int(s)
	M := Int(s)
	nums := scanNums(s, N)
	sums := make([]int, len(nums)+1)
	sums[0] = 0
	sum := 0
	for i, num := range nums {
		sum += num
		sums[i+1] = sum % M
	}
	m := map[int]int{}
	cnt := 0
	for i := len(sums) - 1; i >= 0; i-- {
		n := sums[i]
		if _, ok := m[n]; ok {
			cnt += m[n]
			m[n]++
		} else {
			m[n] = 1
		}
	}
	fmt.Println(cnt)
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

func scanNums(s *bufio.Scanner, len int) (nums []int) {
	for i := 0; i < len; i++ {
		num := Int(s)
		nums = append(nums, num)
	}
	return
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

int main()
{
	int h, w;

	cin >> h >> w;

	vector<int> y;

	string a[h];

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

	REP(i, h){
		int count = 0;
		REP(j, w){
			if (a[i][j] == '.') count++;
		}
		if (count == w) y.push_back(i);
	}

	vector<int> x;

	REP(j, w){
		int count = 0;
		REP(i, h){

			if (a[i][j] == '.') count++;

		}
		if (count == h) x.push_back(j);
	}

	REP(i, h){
		bool flag = true;
		for (int nakamii : y){
			if (nakamii == i) flag = false;
		}
		if (flag == false) continue;
		REP(j, w){
			bool flag2 = true;
			for (int nakamij : x){
				if (nakamij == j) flag2 = false;
			}
			if (flag2 == false) continue;

			cout << a[i][j];

		}

		cout << endl;
	}


}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const in inf=1e9+7;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    string s;
    cin>>s;
    in n=s.size();
    vector<in> amari(2019,0);
    in x=0;
    in cnt10=1;
    for(in i=n-1;i>=0;i--){
        x+=(s[i]-'0')*cnt10;
        x %=2019;
        amari[x] ++;
        cnt10 *=10;
        cnt10 %=2019;
    }
    in ans=amari[0];
    in cnt=(s[n-1]-'0');
    amari[cnt] --;
    cnt10=10;
    for(in i=n-2;i>=0;i--){
        ans +=amari[cnt];
        cnt +=(s[i]-'0')*cnt10;
        cnt %=2019;
        cnt10 *=10;
        cnt10 %=2019;
        amari[cnt] --;
    }
    cout<<ans<<endl;
}/*
./problem.exe
*/

Measured memory_bytes: 3784
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll x = 0;
  cin >> x;
  ll n = 0;
  cin >> n;
  ll res = 0;
  res = 100000;
  vector<bool> count(400);
  for(int i = 0;i < 400;i++)count[i] = false;
  for(int i = 0;i < n;i++){
    ll in = 0;
    cin >> in;
    count[in + 200] = true;
  }
  ll ans = 0;
  for(int i = 0;i < 400;i++){
    if(res > abs(x - (i - 200)) && !count[i]){
      ans = i - 200;
      res = abs(x - (i - 200));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632